Codeforces 460B.Little Dima and Equation
程序员文章站
2023-12-26 23:30:21
...
1 题目描述(题目链接)
2 题解
注意到 s ( x ) s(x) s(x)的值是不超过 81 81 81的,因此可以先枚举出这些数字,然后再检查是否满足等式。
data = input().split()
a, b, c = int(data[0]), int(data[1]), int(data[2])
candidate = [b*i**a + c for i in range(1, 82)]
res = []
def sumx(x):
s = 0
while x:
s += x % 10
x //= 10
return s
for x in candidate:
if 0 < x < 10**9 and b*sumx(x)**a + c == x:
res.append(x)
print(len(res))
for i in res:
print(i, end=" ")