description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Stannis borathean is attacking kings landing from three gates.To defend the city Tyrion again comes up with a fair solution. Tyrion has N soldier troops with given strengths. Tyrion wants to divide army into 3 sets such that the sum of strengths in these three sets are as equal as possible. In other words he wants to m...
import itertools n = eval(input()) repeat = n mylist = [] while n > 0: inp = eval(input()) mylist.append(inp) n = n - 1 minm = 10000000 for i in itertools.product([0, 1, 2], repeat=repeat): g1 = g2 = g3 = 0 for index in range(len(i)): if i[index] == 0: g1 = g1 + mylist[index] ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR LIST NUMBER NUMBER NUMBER VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR...
Stannis borathean is attacking kings landing from three gates.To defend the city Tyrion again comes up with a fair solution. Tyrion has N soldier troops with given strengths. Tyrion wants to divide army into 3 sets such that the sum of strengths in these three sets are as equal as possible. In other words he wants to m...
def divide_to_three(strengths, no_of_troops, ind, s1, s2, s3): if ind == no_of_troops: return max(s1, s2, s3) s11 = divide_to_three(strengths, no_of_troops, ind + 1, s1 + strengths[ind], s2, s3) s12 = divide_to_three(strengths, no_of_troops, ind + 1, s1, s2 + strengths[ind], s3) s13 = divide_to_...
FUNC_DEF IF VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR ...
Stannis borathean is attacking kings landing from three gates.To defend the city Tyrion again comes up with a fair solution. Tyrion has N soldier troops with given strengths. Tyrion wants to divide army into 3 sets such that the sum of strengths in these three sets are as equal as possible. In other words he wants to m...
def find(strengths, n, ind, sum1, sum2, sum3): if ind == n: sum_max = max(sum1, sum2, sum3) return max(sum_max - sum1, sum_max - sum2, sum_max - sum3), sum_max diff1 = find(strengths, n, ind + 1, sum1 + strengths[ind], sum2, sum3) diff2 = find(strengths, n, ind + 1, sum1, sum2 + strengths[in...
FUNC_DEF IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_...
Stannis borathean is attacking kings landing from three gates.To defend the city Tyrion again comes up with a fair solution. Tyrion has N soldier troops with given strengths. Tyrion wants to divide army into 3 sets such that the sum of strengths in these three sets are as equal as possible. In other words he wants to m...
n = int(input()) troops = [int(input()) for i in range(n)] mins1 = sum(troops) tass = [0] * n sum3 = [mins1, 0, 0] for _ in range(3**n): i = n - 1 while i >= 0: aset = tass[i] if aset == 2: sum3[2] = sum3[2] - troops[i] sum3[0] = sum3[0] + troops[i] tass[i] = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER ASSI...
Stannis borathean is attacking kings landing from three gates.To defend the city Tyrion again comes up with a fair solution. Tyrion has N soldier troops with given strengths. Tyrion wants to divide army into 3 sets such that the sum of strengths in these three sets are as equal as possible. In other words he wants to m...
n = int(input()) strengths = [] for troop in range(n): strengths.append(int(input())) sum = sum(strengths) if n <= 3: print(max(strengths)) else: print(sum / 3 + 1)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER
Stannis borathean is attacking kings landing from three gates.To defend the city Tyrion again comes up with a fair solution. Tyrion has N soldier troops with given strengths. Tyrion wants to divide army into 3 sets such that the sum of strengths in these three sets are as equal as possible. In other words he wants to m...
n = int(input()) arr = [int(input()) for e in range(n)] arr2 = [1] * n s_v = [999999, 999999, 9999999] def update(a, b): global s_v temp = [0, 0, 0] for e in range(len(a)): temp[b[e]] += a[e] if temp[0] >= temp[1] and temp[1] >= temp[2] and temp[0] < s_v[0]: s_v = temp def find(a, b,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUM...
Stannis borathean is attacking kings landing from three gates.To defend the city Tyrion again comes up with a fair solution. Tyrion has N soldier troops with given strengths. Tyrion wants to divide army into 3 sets such that the sum of strengths in these three sets are as equal as possible. In other words he wants to m...
n = int(input()) val = [] _sum = 0 for _ in range(n): m = int(input()) val.append(m) _sum += m _mod = _sum % 3 _sum += 3 - _mod num = _sum / 3 if num >= max(val): print(num) else: print(max(val))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC...
Stannis borathean is attacking kings landing from three gates.To defend the city Tyrion again comes up with a fair solution. Tyrion has N soldier troops with given strengths. Tyrion wants to divide army into 3 sets such that the sum of strengths in these three sets are as equal as possible. In other words he wants to m...
import itertools import sys t = eval(input()) tn = t l = [] while t > 0: n = eval(input()) l.append(n) t = t - 1 li = list(range(0, tn)) tsm = sum(l) rt = [] mdiff = 99999 for i in range(1, tn - 1): for j in itertools.combinations(li, i): diff = list(set(li) - set(j)) d = {(0): 0} ...
IMPORT IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CA...
There are $N$ bikers present in a city (shaped as a grid) having $\mbox{M}$ bikes. All the bikers want to participate in the HackerRace competition, but unfortunately only $\mbox{K}$ bikers can be accommodated in the race. Jack is organizing the HackerRace and wants to start the race as soon as possible. He can instruc...
from itertools import chain def Match_Size(Edges): S, T, M = set(), set(), set() G = {} TrG = {} for dist, start, end in Edges: S.add(start) T.add(end) if start not in G: G[start] = [] G[start].append(end) if end not in G: G[end] = [] ...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR LIST IF VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR IF VA...
There are $N$ bikers present in a city (shaped as a grid) having $\mbox{M}$ bikes. All the bikers want to participate in the HackerRace competition, but unfortunately only $\mbox{K}$ bikers can be accommodated in the race. Jack is organizing the HackerRace and wants to start the race as soon as possible. He can instruc...
import sys NIL = 0 MAX_INT = 1000000000000000 def bfs(n1matching, n2matching, n1adj, n2adj): queue = [] dist = [MAX_INT] * len(n1matching) for i in range(1, len(n1matching)): if n1matching[i] == NIL: dist[i] = 0 queue.append(i) while len(queue) > 0: v = queue.p...
IMPORT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR VAR VAR VAR FOR VAR VAR VAR IF VAR VA...
There are $N$ bikers present in a city (shaped as a grid) having $\mbox{M}$ bikes. All the bikers want to participate in the HackerRace competition, but unfortunately only $\mbox{K}$ bikers can be accommodated in the race. Jack is organizing the HackerRace and wants to start the race as soon as possible. He can instruc...
import time def PrintM(Mat, N, M): for i1 in range(N): for i2 in range(M): print(Mat[i1, i2], " ", end="") print("") print("") class Graph: def __init__(self, graph): self.graph = graph self.ppl = len(graph) self.jobs = len(graph[0]) def bpm(sel...
IMPORT FUNC_DEF FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR STRING STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VA...
There are $N$ bikers present in a city (shaped as a grid) having $\mbox{M}$ bikes. All the bikers want to participate in the HackerRace competition, but unfortunately only $\mbox{K}$ bikers can be accommodated in the race. Jack is organizing the HackerRace and wants to start the race as soon as possible. He can instruc...
INF = 1 << 31 def BFS(Adj, Dist, Pair_U, Pair_V, U, V, n): Q = [] for u in U: if Pair_U[u] == n: Dist[u] = 0 Q.append(u) else: Dist[u] = INF Dist[n] = INF while len(Q) > 0: u = Q.pop() if Dist[u] < Dist[n]: for v in Adj[u]...
ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR VAR VAR VAR FOR VAR VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR NUMBER EX...
There are $N$ bikers present in a city (shaped as a grid) having $\mbox{M}$ bikes. All the bikers want to participate in the HackerRace competition, but unfortunately only $\mbox{K}$ bikers can be accommodated in the race. Jack is organizing the HackerRace and wants to start the race as soon as possible. He can instruc...
def bipartiteMatch(graph): matching = {} for u in graph: for v in graph[u]: if v not in matching: matching[v] = u break while 1: preds = {} unmatched = [] pred = dict([(u, unmatched) for u in graph]) for v in matching: ...
FUNC_DEF ASSIGN VAR DICT FOR VAR VAR FOR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR WHILE NUMBER ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR DICT FOR VAR VAR FOR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL FUNC_CALL VAR ...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def main(): a, b, c = [int(i) for i in input().split()] result = [] for S in range(1, 82): f = b * S**a + c if 0 < f < 10**9 and sum(int(i) for i in str(f)) == S: result.append(str(f)) print(len(result)) print(" ".join(result)) main()
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF NUMBER VAR BIN_OP NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL V...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def answer(a, b, c): l = [] for i in range(1, 82): x = b * i**a + c count = 0 t = x while t > 0: count += t % 10 t = t // 10 if count == i and x < 10**9: l.append(x) return l a, b, c = map(int, input().split()) ans = answer(a, b, ...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUN...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def summ(n): a = list(map(int, str(n))) return sum(a) inpt = list(map(int, input().split(" "))) a = inpt[0] b = inpt[1] c = inpt[2] arr = [] count = 0 for i in range(1, 82): num = b * i**a + c if num > 0 and num <= 1000000000 and summ(num) == i: count += 1 arr.append(num) arr = sorted(...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def s(x): res = 0 while x > 0: res += x % 10 x //= 10 return res a, b, c = input().split() a = int(a) b = int(b) c = int(c) ans = [] for sx in range(1, 81): x = b * sx**a + c if x < 10**9: if sx == s(x): ans.append(str(x)) else: break print(len(ans))...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) count = 0 ans = [] def f(x): e = 0 x = list(str(x)) if x.count("-") == 0: for j in x: e += int(j) return e for i in range(1, 82): x = b * i**a + c r = f(x) if x > 0 and i == r: ans.append(x) ans.sort() an = [] for l in ans: ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) l = [] bbb = [] for i in range(1, 82): pp = b * i**a + c p = abs(pp) bb = str(p) aa = list(bb) ans = 0 for j in range(len(aa)): ans += int(aa[j]) bbb.append(ans) if ans == i and pp > 0 and pp < 10**9: l.append(pp) print(len(l)) print(*l...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VA...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) l = [] def s(n): t = 0 while n > 0: t += n % 10 n //= 10 return t for x in range(1, 1000): n = x**a * b + c if s(n) == x and n < 10**9: l.append(str(n)) print(len(l)) print(" ".join(l))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR FU...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) res = [] def f(x): c = 0 for i in range(len(str(x))): c += int(list(str(x))[i]) return c for i in range(1, 82): d = b * i**a + c if d <= 0: continue if d == int(d) and f(d) == i and d < 10**9: res.append(b * i**a + c) if len(res) ==...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
import sys input = lambda: sys.stdin.readline().strip("\r\n") a, b, c = map(int, input().split()) ans = [] for i in range(1, 82): x = b * i**a + c if 0 < x < 10**9: if sum(int(i) for i in str(x)) == i: ans.append(x) print(len(ans)) print(*ans)
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF NUMBER VAR BIN_OP NUMBER NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = list(map(int, input().split())) d = [] r = [] def c_sum(s): s1 = 0 for j in str(s): s1 += int(j) return s1 for i in range(81): v = i + 1 res = b * v**a + c if 1000000000 > res > 0 and c_sum(res) == v: r.append(res) r.sort() print(len(r)) if len(r): print(" ".joi...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF NUMBER VAR NUMBER ...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) res = [] for i in range(1, 82): x = b * i**a + c if 0 < x < 1000000000 and sum(map(int, str(x))) == i: res.append(x) print(len(res)) if res: res.sort() print(*res)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF NUMBER VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VA...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) def S(x: int): return sum(map(int, str(abs(x)))) sols = [] for s in range(1, 81): x = b * s**a + c if s == S(x) and x < 1000000000.0 and x > 0: sols.append(x) print(len(sols)) [print(i, end=" ") for i in sols]
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR ...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) count = 0 ans = [] for i in range(1, 82): x = b * i**a + c if 0 < x < 1000000000.0: if sum([int(j) for j in str(x)]) == i: count += 1 ans.append(x) print(count) if count > 0: print(" ".join([str(i) for i in ans]))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF NUMBER VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split(" ")) ans = [] for s in range(1, 82): x = b * s**a + c if 0 < x < 10**9 and sum(map(int, str(x))) == s: ans.append(x) print(len(ans), str(ans).replace(",", "")[1:-1], sep="\n")
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF NUMBER VAR BIN_OP NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUN...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) sol = 0 li = [] mx = 10**9 for i in range(1, 82): x = b * pow(i, a) + c if x < mx and x > 0: z = str(x) sm = 0 for ele in z: sm += int(ele) if sm == i: sol += 1 li.append(x) print(sol) print(*li)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) ans = [] def sum_digit(num): sum_no = 0 while num >= 10: sum_no += num % 10 num = num // 10 sum_no = sum_no + num return sum_no for _ in range(0, 82): x = b * pow(_, a) + c y = x x = sum_digit(x) if x == _ and y < 1000000000 and y >...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR ASSIG...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split(" ")) res = [] for sx in range(1, 9 * 9 + 1): cur = left = b * sx**a + c if not 0 < cur < 10**9: continue sd = 0 while left > 0: sd += left % 10 left //= 10 if sd == sx: res += [cur] print(len(res)) print(*sorted(res))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF NUMBER VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR LI...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def digits_sum(x): return 0 if x == 0 else x % 10 + digits_sum(x // 10) (a, b, c), ans, arr = map(int, input().split()), 0, [] for i in range(1, 82): if 10**9 >= b * i**a + c > 0 and digits_sum(b * i**a + c) == i: ans += 1 arr.append(b * i**a + c) print(ans) print(*arr)
FUNC_DEF RETURN VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP NUMBER NUMBER BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR V...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def f(x): y = str(x) s = 0 for i in range(len(y)): s += int(y[i]) return s def main(): n = 0 tab = [] a, b, c = map(int, input().split()) for s in range(1, 100): x = b * s**a + c if 0 < x < 1000000000 and f(x) == s: n += 1 tab += [x] ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def s(x): return sum(int(c) for c in str(x)) a, b, c = [int(x) for x in input().split()] ans = [] for i in range(1, 9 * 9): x = b * i**a + c if x <= 0 or x >= 10**9: continue if s(x) == i: ans.append(str(x)) print(len(ans)) print(" ".join(ans))
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER NUMBER IF FUNC_CALL VAR VAR VAR EXPR FU...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def power(x, y): res = 1 while y > 0: if y & 1 == 1: res = res * x y = y >> 1 x = x * x return res def sum_d(n): ans = 0 while n > 0: ans += n % 10 n //= 10 return ans a, b, c = map(int, input().split()) ans = [] cnt = 0 for t in range(1, 8...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN ...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = input().split() a = int(a) b = int(b) c = int(c) def fun(xx): return b * xx**a + c lis = [] for i in range(1, 100): k = fun(i) if k > 0: lis.append(k) ans = [] mx = 10**9 for i in range(len(lis)): k = sum([int(d) for d in str(lis[i])]) chk = lis[i] == fun(k) if lis[i] < mx ...
ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASS...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
ans = list() a, b, c = map(int, input().split()) for sx in range(9 * 9 + 1): x = b * sx**a + c if x > 0 and x < 1000000000: s = sum([int(it) for it in str(x)]) if s == sx: ans.append(x) print(len(ans)) for i in ans: print(i, end=" ")
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR ...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = list(map(int, input().split())) ans = [] for s in range(1, 81 + 1): x = b * s**a + c if x >= 0 and x < 10**9: sx = sum(map(int, list(str(x)))) if sx == s: ans.append(x) ans.sort() print(len(ans)) print(" ".join(map(str, ans)))
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR EXPR F...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
ans = [] a, b, c = list(map(int, input().split())) def sumDig(x): ret = 0 if x <= 0: return 100500 while x: ret += x % 10 x //= 10 return ret for s in range(1, 90): val = b * pow(s, a) + c if 0 < val < 10**9 and sumDig(val) == s: ans.append(val) print(len(ans)...
ASSIGN VAR LIST ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR VAR IF NUMBER VAR BIN_OP NUMBER N...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def sum(N): x = N % 10 N = int(N / 10) while N > 0: x = x + N % 10 N = int(N / 10) return x [a, b, c] = input().split(" ") a = int(a) b = int(b) c = int(c) anss = [] for N in range(1, 81): if (sum(N**a * b + c) == N) & (N**a * b + c < 10**9) & (0 < N**a * b + c): anss = ans...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN LIST VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = list(map(int, input().split())) l = [] for s in range(1, 82): my_x = b * s**a + c if my_x > 0: if s == sum(list(map(int, list(str(my_x))))): if my_x < 10**9: l.append(my_x) if len(l): print(len(l)) for i in l: print(i, end=" ") else: print(0)
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER IF VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) def sum_of_dig(n): if n < 0: return 0 s = 0 n = str(n) for i in n: s += int(i) return s arr = [] for d in range(1, 82): num = pow(d, a) x = b * num + c if d == sum_of_dig(x) and x > 0 and x < pow(10, 9): arr.append(str(x)) p...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR F...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def s(x): x = list(str(x)) sum = 0 for i in range(0, len(x)): sum += int(x[i]) return sum def find_X(a, b, c): ans = [] s_x_max = s(999999999) for S in range(1, s_x_max): X = S**a * b + c if X < 10**9 and X > 0: if s(X) == S: ans.append(X...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF VAR BIN_OP NUMBER NUMBER ...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = list(map(int, input().split())) count = 0 arr = [] def s(x): m = str(x) k = 0 for i in m: k += int(i) return k for y in range(1, 82): p = b * pow(y, a) + c if p > 0 and p < 10**9: if s(p) == y: count += 1 arr.append(p) print(count) for x in a...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER VAR B...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
__author__ = "Ученик" a, b, c = map(int, input().split(" ")) ans = list() for i in range(82): x = b * i**a + c y = x sm = 0 if x <= 0 or x >= 1000000000: continue while y > 0: sm += y % 10 y //= 10 if sm == i: ans.append(x) x = 0 for i in ans: x += 1 print(x) ...
ASSIGN VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CAL...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) def digitsSum(n): res = 0 while n: res += n % 10 n //= 10 return res def f(s): return b * s**a + c ret = [] for s in range(1, 82): x = f(s) if 0 < x < 10**9 and digitsSum(x) == s: ret.append(x) print("%d\n%s" % (len(ret), " ".join...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF NUMBER VAR BIN_OP NUMBER NUMBER FUNC_CALL...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) def ns(n): p = 0 c = 0 while n > 0: p += n % 10 n //= 10 c += 1 return p, c t = [0] * 10 sol = [] for i in range(1, 82): t = b * i**a + c nss = ns(t) if nss[0] == i and nss[1] <= 9: sol.append(t) print(len(sol)) print(*s...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR A...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def digisum(x): ans = 0 while x: ans += x % 10 x = x // 10 return ans fin = [] count = 0 a, b, c = map(int, input().split()) for i in range(1, 82, 1): y = b * i**a + c if y > 0 and y < 1000000000: z = digisum(y) if z == i: count += 1 fin.appe...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def getSum(n): ans = 0 while n != 0: ans += int(n % 10) n = int(n // 10) return ans a, b, c = map(int, input().split()) ans = [] for i in range(82): x = b * i**a + c if x > 0 and x < 1000000000.0 and i == getSum(x): ans.append(x) print(len(ans)) if len(ans) != 0: print(...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR FUN...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def s(n): n = str(n) sum = 0 for i in range(0, len(n)): sum += int(n[i]) return sum a, b, c = map(int, input().split()) ar = [] for i in range(1, 82): ans = b * i**a + c if ans < 0: pass elif s(ans) == i and ans <= 10**9: ar.append(b * i**a + c) print(len(ar)) print...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER IF FU...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def s(i): return sum([int(x) for x in str(i)]) x = [int(i) for i in input().split()] a = x[0] b = x[1] c = x[2] l = [] for k in range(1, 82): n = b * k**a + c if n > 0 and n < 1000000000 and s(n) == k: l.append(n) print(len(l)) for j in l: print(j, end=" ")
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR NUMBER FU...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def s(a, b, c): l = [] for i in range(1, 82): v = b * i**a + c if v > 1000000000: break vcopy = v val = 0 while v > 0: val += v % 10 v //= 10 if val == i: l.append(vcopy) print(len(l)) for i in l: pri...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING A...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) L = [] for i in range(1, 82): val = b * i**a + c check = 0 if val > 0 and val < 10**9: s = str(val) for j in s: check += int(j) if check == i: L.append(val) if len(L) == 0: print(0) else: print(len(L)) print(*L)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF FU...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def dsum(n): r = 0 while n > 0: r += n % 10 n //= 10 return r def main(): a, b, c = map(int, input().split()) res = [] for s in range(82): r = b * s**a + c if dsum(r) == s and 0 < r < 1000000000: res.append(r) print(len(res)) print(" ".join(m...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXP...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def main(): a, b, c = read() res = [] for i in range(1, 82): x = b * i**a + c if x <= 0 or x >= 10**9: continue if sum(map(int, list(str(x)))) == i: res.append(x) res.sort() print(len(res)) print(" ".join(map(str, res))) def read(mode=2): inp...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CA...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def sumdig(x): x = str(x) s = 0 for i in x: s = s + int(i) return s L = [] a, b, c = map(int, input().strip().split()) for i in range(1, 82): x = b * i**a + c if x > 0 and x < 10**9 and i == sumdig(x): L.append(x) print(len(L)) for i in range(len(L)): print(L[i], end=" ")
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR LIST ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBE...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def spam(a): r = 0 for c in str(a): r += int(c) return r a, b, c = map(int, input().split()) r = [] s = 1 for s in range(1, 82): x = b * s**a + c if 0 < x < 10**9 and s == spam(x): r += [str(x)] print(len(r)) print(" ".join(r))
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF NUMBER VAR BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR VA...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def digitsum(x): sm = 0 while x: sm += x % 10 x //= 10 return sm def power(x, a): if a == 0: return 1 z = power(x, a // 2) z *= z if a % 2: z *= x return z [a, b, c] = list(map(int, input().split())) count = 0 val = [] for sm in range(1, 82): num =...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER VAR VAR RETURN VAR ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VA...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
class CodeforcesTask460BSolution: def __init__(self): self.result = "" self.a_b_c = [] def read_input(self): self.a_b_c = [int(x) for x in input().split(" ")] def process_task(self): solutions = set() for y in range(1, 100): sol = self.a_b_c[1] * y ** s...
CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER IF NUMBER VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER IF FUN...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) ans = [] for i in range(1, 82): t = b * i**a + c if t > 0 and t <= 10**9: k = t s = 0 while k: s += k % 10 k //= 10 if s == i: ans.append(t) print(len(ans)) print(*ans)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = [int(ch) for ch in input().split()] sol = [] for i in range(0, 82): x = str(b * i**a + c) s = sum([int(ord(ch) - ord("0")) for ch in x]) if s == i and int(x) > 0 and int(x) < 10**9: sol.append(x) print(len(sol)) for el in sol: print(el, end=" ")
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR IF VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VA...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
from itertools import combinations def cal(cnt): e = 0 while cnt > 0: e += cnt % 10 cnt = cnt // 10 return e a, b, c = map(int, input().split()) ans = set() for i in range(1, 82): som = i cnt = b * som**a + c csom = cal(cnt) if csom == som: if cnt > 0 and cnt < 10...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def calc_sum(x): sum = 0 while x > 0: sum += x % 10 x //= 10 return sum a, b, c = map(int, input().split(" ")) ans = [] for sum in range(1, 81): x = b * sum**a + c if calc_sum(x) == sum and x < 10**9: ans.append(x) print(len(ans)) for item in ans: print(item, end=" ")
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def sum_dig(x): ans = 0 while x != 0: ans += x % 10 x //= 10 return ans a, b, c = list(map(int, input().split())) A = 100 * [0] pos = 0 for sum_dig_x in range(100): x = b * sum_dig_x**a + c if 0 < x < 1000000000 and sum_dig(x) == sum_dig_x: A[pos] = x pos += 1 print...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF NUMBER VAR NUMBER FUNC...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def take_input(s): if s == 1: return int(input()) return map(int, input().split()) a, b, c = take_input(3) rhs = [] def power(a, b): ans = 1 for i in range(b): ans *= a return ans def sm(x): s = 0 while x: s += x % 10 if x > 0: x //= 10 ...
FUNC_DEF IF VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER A...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) l = [] def getSum(n): sum = 0 for digit in str(n): sum += int(digit) return sum for i in range(1, 82): if b * i**a + c < 10**9 and b * i**a + c > 0 and getSum(b * i**a + c) == i: l.append(b * i**a + c) print(len(l)) print(*l)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP NUMBER NUMBER BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR NUMBER FUNC_CALL VAR BI...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = input().split() a, b, c = int(a), int(b), int(c) def sum(a): s = 0 while a != 0: s += a % 10 a = int(a / 10) return s ans = [] for i in range(1, 82): num = b * pow(i, a) + c if sum(num) == i and num > 0 and num < 1000000000: ans.append(num) print(len(ans)) for i...
ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUN...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
D = 9 * 9 a, b, c = map(int, input().split()) OZ = ord("0") r = [] for d in range(1, D): x = b * d**a + c if x <= 0 or 10**9 <= x: continue if d == sum(ord(c) - ord("0") for c in str(x)): r.append(x) print(len(r)) if r: print(*r)
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER BIN_OP NUMBER NUMBER VAR IF VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
X_MAX = 999999999 SUM_MAX = 81 def sum_decimals(number): return sum(map(int, list(str(number)))) def main(): a, b, c = list(map(int, input().split())) solutions = [] for sum_digits in range(1, SUM_MAX + 1): x = b * sum_digits**a + c if X_MAX >= x > 0 and sum_decimals(x) == sum_digits...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR VA...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = input().split(" ") a, b, c = int(a), int(b), int(c) lol = [] for i in range(1, 82): x = b * i**a + c if x > 0 and x < 10**9: y = str(x) s = 0 for j in range(len(y)): s += int(y[j]) if s == i: lol.append(x) print(len(lol)) if len(lol) > 0: pri...
ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUN...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
mm = 10**9 a, b, c = list(map(int, input().split())) arr = [] for k in range(0, 82): ans = b * k**a + c if ans > 0: if sum(list(map(int, list(str(ans))))) == k and ans < mm: arr.append(ans) print(len(arr)) print(*arr)
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR F...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) solutions = [] def check_if_valid_res(number, number_check): x = 0 while number > 0: x += int(number % 10) number = number // 10 return True if x == number_check else False for i in range(1, 82): sum_of_x = i**a approx_res = b * sum_of_x + c ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def summ(num): return sum(map(int, list(str(num)))) a, b, c = map(int, input().split()) lst = [] for i in range(1, 82): x = b * pow(i, a) + c if x > 0: if x < 10**9 and summ(x) == i: lst.append(x) lst.sort() print(len(lst)) if lst != []: print(*lst)
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER IF VAR BIN_OP NUMBER NUMBER FUNC_CALL VAR VAR VAR EXPR FUN...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def mlt(): return map(int, input().split()) a, b, c = mlt() res = [] for n in range(1, 82): v = b * n**a + c if v < 0: continue p = sum(list(map(int, str(v)))) if n == p and v < 10**9: res.append(v) print(len(res)) print(*res)
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP NUMBER NUMBER EXPR...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def sumdigits(x): if x < 10: return x return sumdigits(x // 10) + x % 10 a, b, c = [int(a) for a in input().split()] solutions = [] for i in range(82): x = b * i**a + c if 0 < x and x < 10**9 and sumdigits(x) == i: solutions.append(x) print(len(solutions)) if solutions: print(" ".j...
FUNC_DEF IF VAR NUMBER RETURN VAR RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF NUMBER VAR VAR BIN_OP NUMBER NUMBER FUNC_CALL VAR VAR VAR EXP...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) l = [] for i in range(1, 82): v = str(b * i**a + c) k = 0 for j in range(len(v)): if v[0] == "-": break k = k + int(v[j]) if k == i and v[0] != "-" and int(v) < 1000000000: l.append(v) print(len(l)) print(*l)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER ...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) ans = [] def dsum(x): if x <= 0 or x >= 1000000000.0: return -1 else: ans = 0 for i in str(x): ans += int(i) return ans for s in range(1, 82): x = b * s**a + c if dsum(x) == s: ans.append(x) ans.sort() print(len(...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
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) pr...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FOR VAR VAR IF...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) ans = [] for i in range(1, 82): temp = b * i**a + c if temp > 0 and temp < 10**9: s = str(temp) l = len(s) p = 0 for j in range(l): p += int(s[j]) if p == i: ans.append(temp) ans.sort() print(len(ans)) print(*ans...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
line = input() a = int(line.split(" ")[0]) b = int(line.split(" ")[1]) c = int(line.split(" ")[2]) def k(a, b, c): possibleX = [] x = 0 for i in range(81): x = b * i**a + c if x > 0 and x < 10**9: possibleX.append(x) realx = [] sign = 1 for x in possibleX: t...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING NUMBER FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VA...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = [int(i) for i in input().split()] ans = set() for i in range(1, 10): for j in range(1, 9 * i + 1): x = b * pow(j, a) + c if x > 0 and len(str(x)) == i and sum([int(k) for k in str(x)]) == j: ans.add(x) print(len(ans)) if ans: print(" ".join([str(i) for i in sorted(list(ans)...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def ds(x): return sum([int(c) for c in str(abs(x))]) a, b, c = map(int, input().split()) S = [(b * s**a + c) for s in range(82)] R = sorted([i for i in range(1, 82) if S[i] > 0 and S[i] < 10**9 and i == ds(S[i])]) print(len(R)) print(" ".join([repr(S[i]) for i in R]))
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER VAR VAR NUMBER VAR VAR BIN_OP NUMBER NUMB...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def sum_numbers(number): s = 0 while number > 0: number, r = divmod(number, 10) s += r return s def power(a, b): if b == 0: return 1 elif b % 2 == 0: a_1 = a * a return pow(a_1, b // 2) return a * pow(a, b - 1) def reshenie(A, B, C): result = list(...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def conv(n): n = list(str(n)) n = map(int, n) return sum(n) a, b, c = map(int, input().split()) ans = [] l = 0 for i in range(1, 82): x = b * i**a + c if 0 < x <= 10**9 and conv(x) == i: l += 1 ans.append(x) if l == 0: print(0) else: print(l) print(*ans)
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF NUMBER VAR BIN_OP NUMBER NUM...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def scan(type): return list(map(type, input().split())) a, b, c = scan(int) def digitSum(x): if x // 10 == 0: return x % 10 return x % 10 + digitSum(x // 10) ans = [] for s in range(1, 82): x = b * s**a + c if x > 0 and x < 10**9 and digitSum(x) == s: ans.append(x) print(len(an...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split(" ")) L = [] for s in range(1, 82): x = b * s**a + c t = str(x) if 0 < x < 10**9 and sum(map(int, t)) == s: L.append(t) print(len(L), " ".join(L), sep="\n")
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF NUMBER VAR BIN_OP NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_C...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) A = [] for i in range(1, 82): A.append(i**a) B = [] for i in A: y = b * i + c if y > 0 and sum(list(map(int, list(str(y))))) ** a == i and y < 10**9: B.append(y) print(len(B)) for i in B: print(i, end=" ")
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR V...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) maxx = min(b * 81**a + c, 10**9) l = [] x = 1 def valid(x, k): sum = 0 for c in str(x): sum += int(c) return sum**a == k i = 1 while x <= maxx: k = i**a x = b * k + c if x > 0 and x <= 10**9 and valid(x, k): l.append(x) i += 1 print(len...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN BIN_OP VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) lim = 10**9 arr = [] for i in range(1, 91): x = b * i**a + c s = sum(map(int, str(abs(x)))) if s == i and x > 0 and x < lim: arr.append(x) print(len(arr)) print(*arr)
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def checksum(x): s = 0 while x > 0: s += x % 10 x = x // 10 return s a, b, c = map(int, input().split()) k = 1 sol = [] while k <= 81: x = b * k**a + c if x < 10**9: if k == checksum(x): sol.append(x) k += 1 print(len(sol)) sol = sorted(sol) if len(sol) > 0:...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR BIN_OP NUMBER NUMBER IF VAR FUNC_CALL VAR VAR E...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def SD(a): ans = 0 temp = a while temp > 0: ans += temp % 10 temp //= 10 return ans inp = input().split() a = int(inp[0]) b = int(inp[1]) c = int(inp[2]) l = [] for i in range(1, 82, 1): curr = b * i**a + c if SD(curr) == i: l.append(curr) l2 = [] for i in l: if i >...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
import sys def getSum(n): sum = 0 while n > 0: sum += int(n % 10) n = int(n / 10) return sum a, b, c = map(int, sys.stdin.readline().split()) ans = [] for i in range(1, 82): if getSum(b * i**a + c) == i and b * i**a + c < 10**9 and b * i**a + c > 0: ans.append(b * i**a + c) p...
IMPORT FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER IF FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR VAR BIN_OP B...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def sum_of_digs(num): sum = 0 num_string = str(num) for dig in num_string: sum = sum + int(dig) return sum inpt = input() l = inpt.split() a = int(l[0]) b = int(l[1]) c = int(l[2]) sol = [] j = 0 max_num = 1000000000 for i in range(1, 1000): num = b * i**a + c if num < max_num: ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VA...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def sumn(n, j, i): ans = 0 if len(str(n)) == i: for k in range(i): ans += n % 10 n //= 10 if ans == j: return 1 else: return 0 return 0 a, b, c = map(int, input().split()) l = [] for i in range(1, 10): for j in range(i * 9 + 1): ...
FUNC_DEF ASSIGN VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP ...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = list(map(int, input().split())) ans = [] def sum_digits(n): res = 0 while n > 0: res += n % 10 n //= 10 return res for i in range(1, 82): x = b * i**a + c if 0 < x < 1000000000 and sum_digits(x) == i: ans.append(x) print(len(ans)) if len(ans) > 0: print(*ans...
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF NUMBER VAR NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) s, q = 1, [] while b * s**a + c < 1: s += 1 while s < 82: t = str(b * s**a + c) if len(t) > 9: break if sum(map(int, t)) == s: q.append(t) s += 1 print(len(q)) print(" ".join(q))
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER LIST WHILE BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VA...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def digits(x): x = str(x) ans = 0 for i in range(len(x)): ans += int(x[i]) return ans def solve(a, b, c): track = [] for i in range(1, 82): num = b * i**a + c if num < 0: continue if digits(num) == i and num < int(1000000000.0): track.app...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) def sumd(x): s = 0 while x > 0: s += x % 10 x = x // 10 return s sol = [] for s in range(1, 82): x = b * pow(s, a) + c if x > 0 and x < 1000000000 and sumd(x) == s: sol.append(x) print(len(sol)) for el in sorted(sol): print(el, end=...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR VAR...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
import sys def s(n): aux = str(n) suma = 0 for digit in aux: suma += int(digit) return suma a, b, c = map(int, sys.stdin.readline().strip().split(" ")) values = [] for i in range(1, 82): x = b * i**a + c if x > 0 and x < 1000000000.0: if s(x) == i: values.append(s...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR NUMBER IF FUNC_C...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
def lhs(x): if x <= 0: return 0 string = str(x) add = 0 for i in range(len(string)): add += int(string[i]) return add def main(): a, b, c = map(int, input().split()) ans = [] for i in range(1, 82): x = b * i**a + c x1 = lhs(int(x)) if x1 == i and...
FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP V...
Little Dima misbehaved during a math lesson a lot and the nasty teacher Mr. Pickles gave him the following problem as a punishment. Find all integer solutions x (0 < x < 10^9) of the equation:x = b·s(x)^{a} + c, where a, b, c are some predetermined constant values and function s(x) determines the sum of all digits...
a, b, c = map(int, input().split()) i = 0 def summ_digit(number): i = 0 summ = 0 num = str(number) while len(num) > i: summ += int(num[i]) i += 1 return summ c1 = [0] * 81 for s in range(1, 82): n = b * s**a + c if n > 0 and summ_digit(n) == s and n < 10**9: c1[i]...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP ...