#include <iostream>
#include <cmath>
using namespace std;

bool isSelfNum(int num) {
    int sum = 0;
    int temp = num;
    int n = to_string(num).length();
    
    while (temp > 0) {
        int digit = temp % 10;
        sum += pow(digit, n);
        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/qoLK 著作权归作者所有。请勿转载和采集!

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