#include <cstdio>
#include <iostream>
using namespace std;
int cnt1,sum1[9999];
int cnt2,sum2[9999];
char w[100]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};//打表大法好233333
long long zh1(int x,int b)
{
cnt1=0;
while(x)
{
sum1[++cnt1]=x%b;
x/=b;//进制转换
}
}
long long zh2(int x,int b)
{
cnt2=0;
while(x)
{
sum2[++cnt2]=x%b;
x/=b;
}
}
int pd()
{
for(int i=1;i<=cnt1;i++)
if(sum1[cnt1-i+1]!=sum1[i])
return 0;
return 1;
}
int main()
{
int b;
scanf("%d",&b);
for(int i=1;i<=300;i++)
{
long long ans=zh1(i*i,b);
if(pd()==1)
{
zh2(i,b);
for(int j=cnt2;j>=1;j--)
printf("%c",w[sum2[j]]);
printf(" ");
for(int j=cnt1;j>=1;j--)
printf("%c",w[sum1[j]]);
puts("");
}
}
return 0;
}
回文平方数
最新推荐文章于 2024-06-17 11:41:05 发布