问题标题: 酷町堂:10182

0
0
已解决
孙天意
孙天意
资深守护
资深守护

#include<iostream>

#include<cmath>

using namespace std;

int main(){

    long long n,a,s,sum=0;

    cin>>n;

    for(int i=1;i<=n;i++){

        cin>>a;

        sum=0;

        s=a;

        while(s){

            int x=s%10;

            sum+=pow(x,n);

            s/=10;

        }

        if(sum==a){

            cout<<"T"<<endl;

        }else{

            cout<<"F"<<endl;

        }

    }

    return 0;

}


0
已采纳
张洪睿
张洪睿
资深守护
资深守护

第10行后面要统计位数cnt,初值要清零,再把a赋值给s,第2个循环的sum就是加上x的cnt次方

1
我要回答