//依然是进制转换和回文的判断了,应该没啥好说的吧。
program dualpal;
var
n,s,tot,sum:longint;
a:array [0..10000] of longint;
b:array [0..15000] of longint;
function check:boolean;
var
i:longint;
begin
if (a[1]=0) or (a[tot]=0) then exit(false);
for i:=1 to tot do if a[i]<>a[tot-i+1] then exit(false);
exit(true);
end;
procedure change(x,y:longint);
var
t,temp:longint;
begin
tot:=0;
temp:=x;
while x<>0 do
begin
t:=x mod y;
inc(tot);
a[tot]:=t;
x:=x div y;
end;
if check then inc(b[temp]);
end;
procedure main;
var
i:longint;
begin
sum:=0;
while 1=1 do
begin
inc(s);
for i:=2 to 10 do
begin
change(s,i);
if b[s]=2 then
begin
inc(sum);
writeln(s);
break;
end;
end;
if sum=n then exit;
end;
end;
begin
readln(n,s);
main;
end.
Dual Palindromes (dualpal)[USACO 1.2.5]
最新推荐文章于 2020-10-08 11:37:45 发布