#include<stdio.h>
#include<stdlib.h>
int c[30],b;
bool pd(int n){
int i;
for(i=1;i<=n;i++)
if(c[i]!=c[n-i+1])
return false;
return true;
}
void jz(int n){
int ch[30],i=1,j,m=n;
while(m>0){
ch[i]=m%b;
m/=b;
i++;
}
for(j=i-1;j>=1;j--)
if(ch[j]<=9)printf("%d",ch[j]);
else printf("%c",(char)(ch[j]+55));
}
void work(int n){
int i=1,j,k,m=n*n;
while(m>0){
c[i]=m%b;
m/=b;
i++;
}
if(pd(i-1)){
jz(n);
printf(" ");
jz(n*n);
puts("");
}
return;
}
int main(){
freopen("palsquare.in","r",stdin);
freopen("palsquare.out","w",stdout);
scanf("%d",&b);
int i;
for(i=1;i<=300;i++)
work(i);
return 0;
}
usaco palsquare
最新推荐文章于 2017-05-25 19:53:30 发布