解题思路:
注意事项:
参考代码:
n = int(input()) flag = 0 for i in range(10000, 1000000): if str(i) == str(i)[::-1] and sum(map(int, list(str(i)))) == n: print(i) flag = 1 continue if not flag: print(-1)
0.0分
0 人评分
num = int(input()) num1 = 0 n3 = int(0) n4 = int(0) n5 = int(0) for i in range(1,10): n3 = i for j in range(1,10): n4 = j for k in range(1,10): n5 = k #五位数判断 if (n3*2)+(n4*2)+n5==num: print((10000*n3)+(1000*n4)+(100*n5)+(10*n4)+n3) num1+=1 #六位数判断 if (n3*2)+(n4*2)+(n5*2)==num: print((100000*n3)+(10000*n4)+(1000*n5)+(100*n5)+(10*n4)+n3) num1+=1 #list.append(2) ##不满足条件输出-1 if num==0: print(-1)