#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int B;
string train(int x)
{
string ans;
while(x)
{
if(x%B<10)
{
ans+='0'+x%B;
}
else
{
ans+='A'+(x%B-10);
}
x=x/B;
}
reverse(ans.begin(),ans.end());
return ans;
}
bool judge(int x)
{
string s=train(x);
string s1=s;
reverse(s1.begin(),s1.end());
if(s1==s)
return true;
else
return false;
}
int main()
{
cin>>B;
for(int i=1; i<=300; i++)
{
if(judge(i*i))
{
cout<<train(i)<<" "<<train(i*i)<<endl;
}
}
return 0;
}
回文平方数(选做)
猜你喜欢
转载自blog.csdn.net/chen_zan_yu_/article/details/105234695
今日推荐
周排行