If a number (the first digit is not zero) is read from left to right as well as from right to left, we call it Title: [noip1999] palindrome number Title Description If a number read from left to right is the same as a number read from right to left, we call it palindrome number For example: given a decimal number 56, add 56 to 65 (that is, read 56 from right to left), and 121 is a palindrome number Another example: for decimal number 87: STEP1:87+78 = 165 STEP2:165+561 = 726 STEP3:726+627 = 1353 STEP4:1353+3531 = 4884 The step here refers to an n-ary addition. In the above example, it takes at least 4 steps to get the palindrome number 4884 Input format The first line is the integer n (2)

If a number (the first digit is not zero) is read from left to right as well as from right to left, we call it Title: [noip1999] palindrome number Title Description If a number read from left to right is the same as a number read from right to left, we call it palindrome number For example: given a decimal number 56, add 56 to 65 (that is, read 56 from right to left), and 121 is a palindrome number Another example: for decimal number 87: STEP1:87+78 = 165 STEP2:165+561 = 726 STEP3:726+627 = 1353 STEP4:1353+3531 = 4884 The step here refers to an n-ary addition. In the above example, it takes at least 4 steps to get the palindrome number 4884 Input format The first line is the integer n (2)

This problem is also very simple, just test some basic programming ability, there is no difficulty to speak of. As long as careful, the score of this problem is easy to get
Here, the number is represented by string (other methods can also be used), because it is easy to handle
The addition of n-ary system is the most important part of this problem
1) Character > number, you can simplify the program with array, that is, digit and chars array
2) Do addition, keep the numbers and carry, just like doing high precision addition
G is carry
const
step:integer=0;
chars:array [0..15] of char=('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');
var
digit:array [char] of integer;
i,n,g:integer;
m,s:string;
ok:boolean;
begin
for i:=0 to 9 do digit[char(ord('0')+i)]:=i;
for i:=0 to 5 do digit[char(ord('A')+i)]:=i+10;
write('n='); readln(n);
write('m='); readln(s);
for i:=1 to length(s) do s[i]:=upcase(s[i]);
repeat
ok:=true;
for i:=1 to length(s) div 2 do
if s[i]s[length(s)+1-i] then ok:=false;
if ok then break;
inc(step);
m:=s; g:=0;
for i:=length(m) downto 1 do
begin
s[i]:=chars[(digit[m[i]]+digit[m[length(m)+1-i]]+g) mod n];
g:=(digit[m[i]]+digit[m[length(m)+1-i]]+g) div n;
end;
if g>0 then s:=chars[g]+s;
until step>=30;
if ok then
writeln('STEP=',step)
else
writeln('Impossible');
end.
If you have any questions, please accept them