算法设计与编程 自幂数判读 知识点:拆位 简单一次过

67 阅读1分钟

赛氪OJ-专注于算法竞赛的在线评测系统 (saikr.com)

#include<bits/stdc++.h> 
using namespace std;
vector<int> v;
int x,sum;
void chai(int x)
{
	v.clear();
	while(x)
	{
	    v.push_back(x%10);
     	x/=10;
	}
} 

void sovel()
{
	sum=0;
	cin>>x;
	
	chai(x);
	int len=v.size();

	for(auto& it:v)
	{
		sum+=pow(it,len);
	}
	if(sum==x)cout<<"T"<<endl;
	else cout<<"F"<<endl;
}
int main()
{
     
   int t;cin>>t;
   while(t--)
   {
      sovel();	
   }	
	
	return 0;
}