题解 | #[NOIP1999]回文数#
[NOIP1999]回文数
http://www.nowcoder.com/practice/a432eb24b3534c27bdd1377869886ebb
a=int(input())
b=input()
num=0
while a==10 and b!=''.join([i for i in reversed(b)]):
b=str(int(b)+int(''.join([i for i in reversed(b)])))
num+=1
if num>30:
print('imposs')
break
while a==2 and b!=''.join([i for i in reversed(b)]):
b=bin(int(b,2)+int(''.join([i for i in reversed(b)]),2))[2:]
num+=1
if num>30:
print('Impossible!')
break
while a==16 and b!=''.join([i for i in reversed(b)]):
b=hex(int(b,16)+int(''.join([i for i in reversed(b)]),16))[2:]
num+=1
if num>30:
print('imposs')
break
if num<=30:
print('STEP=%d'%(num))