var
a,b:string;
zh:array [0..19] of char=('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J');
n,i,j,l,t:longint;
bj:boolean;
begin
readln(n);
for i:=1 to 300 do
begin
t:=i*i; a:=''; bj:=true; l:=0;
while t>0 do
begin
inc(l);
a[l]:=zh[t mod n];
t:=t div n;
end;
for j:=1 to l div 2 do
if a[j]<>a[l+1-j] then begin bj:=false; break; end;
if bj then begin
t:=i; b:=''; bj:=true;
while t>0 do
begin
b:=zh[t mod n]+b;
t:=t div n;
end;
write(b,' ');
for j:=1 to l do
write(a[j]);
writeln;
end;
end;
end.
一大堆的福利之【USACO题库】 Palindromic Squares回文平方数
最新推荐文章于 2023-07-15 11:36:27 发布