#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int i,j;
for(i = 0;i<n;i++){
int s1,s2;
cin>>s1;
for(j = 0;j<10;j++){
if(j==0){
if(s1==0) cout<<0<<""<<0<<endl;
}else{
s2 = j*s1*s1;
string str1 = to_string(s1);
string str2 = to_string(s2);
//cout<<str1<<" "<<str2<<endl;
//cout<<str1<<" "<<str2.substr(str2.size()-str1.size(),str1.size())<<" "<<str2<<endl;
if(str1==str2.substr(str2.size()-str1.size(),str1.size())){
cout<<j<<" "<<str2<<endl;
break;
}
}
}
if(j>=10){
cout<<"No"<<endl;
}
}
return 0;
}
PAT (Basic Level) Practice (中文)1091 N-自守数
最新推荐文章于 2024-09-14 22:25:23 发布