#include #include using namespace std;

bool isSelfNum(int num) { int sum = 0; int temp = num; int digit = 0; while (temp > 0) { temp /= 10; digit++; } temp = num; while (temp > 0) { int remainder = temp % 10; sum += pow(remainder, digit); temp /= 10; } return sum == num; }

int main() { int M; cin >> M; for (int i = 0; i < M; i++) { int num; cin >> num; if (isSelfNum(num)) { cout << 'T' << endl; } else { cout << 'F' << endl; } } return 0; }

C++ 判断自幂数算法实现

原文地址: https://www.cveoy.top/t/topic/qoK6 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录