就这两个样例错了,也不知道为啥。我的代码和题解思路一样的。
n = int(input())
instr = input()
l = []
for ch in instr:
try:
l.append(int(ch,base=n))
except Exception:
pass
for STEP in range(30):
up = 0
s,l = ''.join(map(str,l)),[]
if s == s[::-1]:
print(f'STEP={STEP}')
break
for i in range(len(s)):
sum = int(s[i])+int(s[-1-i])+up
up = 0
l.append(sum%n)
if sum >= n: up = 1
sum = 0
if up == 1: l.append(1)
if STEP > 29:
print('Impossible!')