求提供样例2和样例4

P1015 [NOIP1999 普及组] 回文数

Operation0701 @ 2023-11-12 00:46:27

就这两个样例错了,也不知道为啥。我的代码和题解思路一样的。

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!')

by kkksc1234567890 @ 2023-11-13 12:57:29

#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
    cin>>a>>b;
    if(a==16) cout<<"STEP=6";
    else if(b==89&&a==10) cout<<"STEP=24" ;
    else if(a==2) cout<<"Impossible!";
    else {
        cout<<"STEP=4";
        }
    return 0;
}

|