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 make three sums S1, S2 and S3 using all troops with constraint that S1 ≥ S2 ≥ S3 and S1 is as less as possible. Input Input contains integer N which is number of troops followed by N lines. Each line contains an integer, strength of one of the troop. Output Strength of strongest set that is sum S1. Constraints: 1 ≤ N ≤ 12 1 ≤ Strength of each troop ≤ 100 SAMPLE INPUT 4 3 4 1 3 SAMPLE OUTPUT 4 Explanation The numbers can be divided into three sets S1, S2 and S3 following the condition S1 ≥ S2 ≥ S3 if S1=4, S2=4 and S3=3. Hence the answer is S1=4
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] elif i[index] == 1: g2 = g2 + mylist[index] elif i[index] == 2: g3 = g3 + mylist[index] maxm = max(g1, g2, g3) if maxm < minm: minm = maxm print(minm)
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 IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR 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 make three sums S1, S2 and S3 using all troops with constraint that S1 ≥ S2 ≥ S3 and S1 is as less as possible. Input Input contains integer N which is number of troops followed by N lines. Each line contains an integer, strength of one of the troop. Output Strength of strongest set that is sum S1. Constraints: 1 ≤ N ≤ 12 1 ≤ Strength of each troop ≤ 100 SAMPLE INPUT 4 3 4 1 3 SAMPLE OUTPUT 4 Explanation The numbers can be divided into three sets S1, S2 and S3 following the condition S1 ≥ S2 ≥ S3 if S1=4, S2=4 and S3=3. Hence the answer is S1=4
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_three(strengths, no_of_troops, ind + 1, s1, s2, s3 + strengths[ind]) return min(s11, s12, s13) if __name__ == "__main__": no_of_troops = int(input()) strengths = [int(input()) for ind in range(no_of_troops)] print(divide_to_three(strengths, no_of_troops, 0, 0, 0, 0))
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 IF VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER 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 make three sums S1, S2 and S3 using all troops with constraint that S1 ≥ S2 ≥ S3 and S1 is as less as possible. Input Input contains integer N which is number of troops followed by N lines. Each line contains an integer, strength of one of the troop. Output Strength of strongest set that is sum S1. Constraints: 1 ≤ N ≤ 12 1 ≤ Strength of each troop ≤ 100 SAMPLE INPUT 4 3 4 1 3 SAMPLE OUTPUT 4 Explanation The numbers can be divided into three sets S1, S2 and S3 following the condition S1 ≥ S2 ≥ S3 if S1=4, S2=4 and S3=3. Hence the answer is S1=4
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[ind], sum3) diff3 = find(strengths, n, ind + 1, sum1, sum2, sum3 + strengths[ind]) return min(diff1, diff2, diff3) n = int(input()) strengths = sorted([int(input()) for i in range(n)], reverse=True) print(find(strengths, n, 1, strengths[0], 0, 0)[1])
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_OP VAR NUMBER VAR VAR BIN_OP VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER NUMBER 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 make three sums S1, S2 and S3 using all troops with constraint that S1 ≥ S2 ≥ S3 and S1 is as less as possible. Input Input contains integer N which is number of troops followed by N lines. Each line contains an integer, strength of one of the troop. Output Strength of strongest set that is sum S1. Constraints: 1 ≤ N ≤ 12 1 ≤ Strength of each troop ≤ 100 SAMPLE INPUT 4 3 4 1 3 SAMPLE OUTPUT 4 Explanation The numbers can be divided into three sets S1, S2 and S3 following the condition S1 ≥ S2 ≥ S3 if S1=4, S2=4 and S3=3. Hence the answer is S1=4
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] = 0 else: sum3[aset] = sum3[aset] - troops[i] sum3[aset + 1] = sum3[aset + 1] + troops[i] tass[i] = aset + 1 break i = i - 1 maxs = max(sum3) if maxs < mins1: mins1 = maxs print(mins1)
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 ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR 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 make three sums S1, S2 and S3 using all troops with constraint that S1 ≥ S2 ≥ S3 and S1 is as less as possible. Input Input contains integer N which is number of troops followed by N lines. Each line contains an integer, strength of one of the troop. Output Strength of strongest set that is sum S1. Constraints: 1 ≤ N ≤ 12 1 ≤ Strength of each troop ≤ 100 SAMPLE INPUT 4 3 4 1 3 SAMPLE OUTPUT 4 Explanation The numbers can be divided into three sets S1, S2 and S3 following the condition S1 ≥ S2 ≥ S3 if S1=4, S2=4 and S3=3. Hence the answer is S1=4
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 make three sums S1, S2 and S3 using all troops with constraint that S1 ≥ S2 ≥ S3 and S1 is as less as possible. Input Input contains integer N which is number of troops followed by N lines. Each line contains an integer, strength of one of the troop. Output Strength of strongest set that is sum S1. Constraints: 1 ≤ N ≤ 12 1 ≤ Strength of each troop ≤ 100 SAMPLE INPUT 4 3 4 1 3 SAMPLE OUTPUT 4 Explanation The numbers can be divided into three sets S1, S2 and S3 following the condition S1 ≥ S2 ≥ S3 if S1=4, S2=4 and S3=3. Hence the answer is S1=4
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, curr=0): if curr == len(a): update(a, b) else: for e in range(3): b[curr] = e find(a, b, curr + 1) find(arr, arr2) print(s_v[0])
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 NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_DEF NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR 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 make three sums S1, S2 and S3 using all troops with constraint that S1 ≥ S2 ≥ S3 and S1 is as less as possible. Input Input contains integer N which is number of troops followed by N lines. Each line contains an integer, strength of one of the troop. Output Strength of strongest set that is sum S1. Constraints: 1 ≤ N ≤ 12 1 ≤ Strength of each troop ≤ 100 SAMPLE INPUT 4 3 4 1 3 SAMPLE OUTPUT 4 Explanation The numbers can be divided into three sets S1, S2 and S3 following the condition S1 ≥ S2 ≥ S3 if S1=4, S2=4 and S3=3. Hence the answer is S1=4
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_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 make three sums S1, S2 and S3 using all troops with constraint that S1 ≥ S2 ≥ S3 and S1 is as less as possible. Input Input contains integer N which is number of troops followed by N lines. Each line contains an integer, strength of one of the troop. Output Strength of strongest set that is sum S1. Constraints: 1 ≤ N ≤ 12 1 ≤ Strength of each troop ≤ 100 SAMPLE INPUT 4 3 4 1 3 SAMPLE OUTPUT 4 Explanation The numbers can be divided into three sets S1, S2 and S3 following the condition S1 ≥ S2 ≥ S3 if S1=4, S2=4 and S3=3. Hence the answer is S1=4
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} td = {(0): 0} for k in diff: d.update(td) td = {(0): 0} for w in d: td[l[k] + w] = 1 d.update(td) sm2 = max(d) s3 = tsm - sm2 for p in d: tr = [s3, abs(sm2 - p), abs(p)] tr.sort() if abs(tr[2] - tr[0]) < mdiff: rt = tr mdiff = abs(tr[2] - tr[0]) print(rt[2])
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_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR DICT NUMBER NUMBER ASSIGN VAR DICT NUMBER NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR DICT NUMBER NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER
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 instruct any biker to move towards any bike in the city. In order to minimize the time to start the race, Jack instructs the bikers in such a way that the first $\mbox{K}$ bikes are acquired in the minimum time. Every biker moves with a unit speed and one bike can be acquired by only one biker. A biker can proceed in any direction. Consider distance between bikes and bikers as Euclidean distance. Jack would like to know the square of required time to start the race as soon as possible. Input Format The first line contains three integers, $N$, $\mbox{M}$, and $\mbox{K}$, separated by a single space. The following $N$ lines will contain $N$ pairs of integers denoting the co-ordinates of $N$ bikers. Each pair of integers is separated by a single space. The next $\mbox{M}$ lines will similarly denote the co-ordinates of the $\mbox{M}$ bikes. Constraints $1\leq N\leq250$ $1\leq M\leq250$ $1\leq K\leq min(N,M)$ $0\leq x_i$, $y_i$ $\leq10$$7$ Output Format A single line containing the square of required time. Sample Input 3 3 2 0 1 0 2 0 3 100 1 200 2 300 3 Sample Output 40000 Explanation There's need for two bikers for the race. The first biker (0,1) will be able to reach the first bike (100,1) in 100 time units. The second biker (0,2) will be able to reach the second bike (200,2) in 200 time units. This is the most optimal solution and will take 200 time units. So output will be 200^{2} = 40000.
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] = [] if end not in TrG: TrG[end] = [] TrG[end].append(start) if start not in TrG: TrG[start] = [] while S: s = S.pop() Q, P = {s}, {} while Q: u = Q.pop() if u in T: T.remove(u) break forw = (v for v in G[u] if (u, v) not in M) back = (v for v in TrG[u] if (v, u) in M) for v in chain(forw, back): if v in P: continue P[v] = u Q.add(v) while u != s: u, v = P[u], u if v in G[u]: M.add((u, v)) else: M.remove((v, u)) return len(M) N, M, K = map(int, input().split()) a = [] b = [] for n in range(N): y, x = map(int, input().split()) a.append((n, y, x)) for m in range(M): y, x = map(int, input().split()) b.append((m, y, x)) c = [] for n, y1, x1 in a: for m, y2, x2 in b: dist = (y2 - y1) ** 2 + (x2 - x1) ** 2 c.append((dist, n, N + m)) c = sorted(c) lo = 0 hi = len(c) - 1 while lo < hi: mid = (hi + lo) // 2 match_size = Match_Size(c[: mid + 1]) if match_size >= K: hi = mid else: lo = mid + 1 print(c[lo][0])
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 VAR VAR ASSIGN VAR VAR LIST WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR DICT WHILE VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR VAR VAR VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR 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 LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR VAR FOR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER
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 instruct any biker to move towards any bike in the city. In order to minimize the time to start the race, Jack instructs the bikers in such a way that the first $\mbox{K}$ bikes are acquired in the minimum time. Every biker moves with a unit speed and one bike can be acquired by only one biker. A biker can proceed in any direction. Consider distance between bikes and bikers as Euclidean distance. Jack would like to know the square of required time to start the race as soon as possible. Input Format The first line contains three integers, $N$, $\mbox{M}$, and $\mbox{K}$, separated by a single space. The following $N$ lines will contain $N$ pairs of integers denoting the co-ordinates of $N$ bikers. Each pair of integers is separated by a single space. The next $\mbox{M}$ lines will similarly denote the co-ordinates of the $\mbox{M}$ bikes. Constraints $1\leq N\leq250$ $1\leq M\leq250$ $1\leq K\leq min(N,M)$ $0\leq x_i$, $y_i$ $\leq10$$7$ Output Format A single line containing the square of required time. Sample Input 3 3 2 0 1 0 2 0 3 100 1 200 2 300 3 Sample Output 40000 Explanation There's need for two bikers for the race. The first biker (0,1) will be able to reach the first bike (100,1) in 100 time units. The second biker (0,2) will be able to reach the second bike (200,2) in 200 time units. This is the most optimal solution and will take 200 time units. So output will be 200^{2} = 40000.
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.pop() if dist[v] < dist[NIL]: for u in n1adj[v]: if dist[n2matching[u]] == MAX_INT: dist[n2matching[u]] = dist[v] + 1 queue.append(n2matching[u]) return dist[NIL] != MAX_INT, dist def dfs(v, n1adj, dist, n1matching, n2matching): if v != NIL: for u in n1adj[v]: if dist[n2matching[u]] == dist[v] + 1: if dfs(n2matching[u], n1adj, dist, n1matching, n2matching): n2matching[u] = v n1matching[v] = u return True dist[v] = MAX_INT return False return True def hk(graph, matching_limit): N1, N2, n1adj, n2adj = graph n1matching = [NIL] * (N1 + 1) n2matching = [NIL] * (N2 + 1) matching_count = 0 while True: result, dist = bfs(n1matching, n2matching, n1adj, n2adj) if not result: break for v in range(1, N1 + 1): if n1matching[v] == NIL: if dfs(v, n1adj, dist, n1matching, n2matching): matching_count += 1 if matching_count >= matching_limit: return True return False def construct_bipartite_graph(N, M, dists, dist_limit): n1adj = [] n2adj = [] for i in range(N + 1): n1adj.append([]) for i in range(M + 1): n2adj.append([]) for i in range(1, N + 1): for j in range(1, M + 1): if dists[i][j] <= dist_limit: n1adj[i].append(j) n2adj[j].append(i) return N, M, n1adj, n2adj def node_dist(n1, n2): return (n1[0] - n2[0]) * (n1[0] - n2[0]) + (n1[1] - n2[1]) * (n1[1] - n2[1]) def try_dist_limit(N, M, K, dists, dist_limit): graph = construct_bipartite_graph(N, M, dists, dist_limit) return hk(graph, K) def bike_racers(): N, M, K = [int(x) for x in sys.stdin.readline().split()] racers = [] for _ in range(N): x1, x2 = [int(x) for x in sys.stdin.readline().split()] racers.append((x1, x2)) bikes = [] for _ in range(M): x1, x2 = [int(x) for x in sys.stdin.readline().split()] bikes.append((x1, x2)) dists = [] for _ in range(N + 1): dists.append([-1] * (M + 1)) total_dists = set() for i in range(1, N + 1): for j in range(1, M + 1): dists[i][j] = node_dist(racers[i - 1], bikes[j - 1]) total_dists.add(dists[i][j]) total_dists = sorted(list(total_dists)) low = 0 up = len(total_dists) - 1 while low < up: mid = int((low + up) / 2) if try_dist_limit(N, M, K, dists, total_dists[mid]): up = mid else: low = mid + 1 if try_dist_limit(N, M, K, dists, total_dists[min(up, low)]): return total_dists[min(up, low)] else: return total_dists[max(up, low)] print(bike_racers())
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 VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR RETURN VAR VAR VAR VAR FUNC_DEF IF VAR VAR FOR VAR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR
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 instruct any biker to move towards any bike in the city. In order to minimize the time to start the race, Jack instructs the bikers in such a way that the first $\mbox{K}$ bikes are acquired in the minimum time. Every biker moves with a unit speed and one bike can be acquired by only one biker. A biker can proceed in any direction. Consider distance between bikes and bikers as Euclidean distance. Jack would like to know the square of required time to start the race as soon as possible. Input Format The first line contains three integers, $N$, $\mbox{M}$, and $\mbox{K}$, separated by a single space. The following $N$ lines will contain $N$ pairs of integers denoting the co-ordinates of $N$ bikers. Each pair of integers is separated by a single space. The next $\mbox{M}$ lines will similarly denote the co-ordinates of the $\mbox{M}$ bikes. Constraints $1\leq N\leq250$ $1\leq M\leq250$ $1\leq K\leq min(N,M)$ $0\leq x_i$, $y_i$ $\leq10$$7$ Output Format A single line containing the square of required time. Sample Input 3 3 2 0 1 0 2 0 3 100 1 200 2 300 3 Sample Output 40000 Explanation There's need for two bikers for the race. The first biker (0,1) will be able to reach the first bike (100,1) in 100 time units. The second biker (0,2) will be able to reach the second bike (200,2) in 200 time units. This is the most optimal solution and will take 200 time units. So output will be 200^{2} = 40000.
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(self, u, matchR, seen): for v in range(self.jobs): if self.graph[u][v] and seen[v] == False: seen[v] = True if matchR[v] == -1 or self.bpm(matchR[v], matchR, seen): matchR[v] = u return True return False def maxBPM(self): matchR = [-1] * self.jobs result = 0 for i in range(self.ppl): seen = [False] * self.jobs if self.bpm(i, matchR, seen): result += 1 return result N, M, K = [int(m) for m in input().strip().split()] RiderList = [] BikeList = [] for i in range(N): X, Y = [int(m) for m in input().strip().split()] RiderList.append((X, Y)) for i in range(M): X, Y = [int(m) for m in input().strip().split()] BikeList.append((X, Y)) DistSq = {} DistMax = 0 DistMin = 10000000000.0 for i1 in range(N): for i2 in range(M): DiSq = (RiderList[i1][0] - BikeList[i2][0]) ** 2 + ( RiderList[i1][1] - BikeList[i2][1] ) ** 2 DistSq[i1, i2] = DiSq if DiSq > DistMax: DistMax = DiSq if DiSq < DistMin: DistMin = DiSq if DistMax == 0: print(0) else: st = time.time() left = [DistMin - 1, 0] right = [DistMax, min(N, M)] for Tempi in range(40): Cutoff = (left[0] + right[0]) // 2 bpGraph = [[(0) for i1 in range(N)] for i2 in range(M)] for i1 in range(N): for i2 in range(M): if DistSq[i1, i2] <= Cutoff: bpGraph[i2][i1] = 1 g = Graph(bpGraph) nPair = g.maxBPM() if nPair >= K: right = [Cutoff, nPair] else: left = [Cutoff, nPair] if right[0] - left[0] == 1: break print(int(right[0]))
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 VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF FUNC_CALL VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR LIST VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER
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 instruct any biker to move towards any bike in the city. In order to minimize the time to start the race, Jack instructs the bikers in such a way that the first $\mbox{K}$ bikes are acquired in the minimum time. Every biker moves with a unit speed and one bike can be acquired by only one biker. A biker can proceed in any direction. Consider distance between bikes and bikers as Euclidean distance. Jack would like to know the square of required time to start the race as soon as possible. Input Format The first line contains three integers, $N$, $\mbox{M}$, and $\mbox{K}$, separated by a single space. The following $N$ lines will contain $N$ pairs of integers denoting the co-ordinates of $N$ bikers. Each pair of integers is separated by a single space. The next $\mbox{M}$ lines will similarly denote the co-ordinates of the $\mbox{M}$ bikes. Constraints $1\leq N\leq250$ $1\leq M\leq250$ $1\leq K\leq min(N,M)$ $0\leq x_i$, $y_i$ $\leq10$$7$ Output Format A single line containing the square of required time. Sample Input 3 3 2 0 1 0 2 0 3 100 1 200 2 300 3 Sample Output 40000 Explanation There's need for two bikers for the race. The first biker (0,1) will be able to reach the first bike (100,1) in 100 time units. The second biker (0,2) will be able to reach the second bike (200,2) in 200 time units. This is the most optimal solution and will take 200 time units. So output will be 200^{2} = 40000.
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]: if Dist[Pair_V[v]] == INF: Dist[Pair_V[v]] = Dist[u] + 1 Q.append(Pair_V[v]) return Dist[n] != INF def DFS(Adj, Dist, Pair_V, Pair_U, u, n): if u != n: for v in Adj[u]: if Dist[Pair_V[v]] == Dist[u] + 1: if DFS(Adj, Dist, Pair_V, Pair_U, Pair_V[v], n) == True: Pair_V[v] = u Pair_U[u] = v return True Dist[u] = INF return False return True def HopcroftKarp(Adj, n, m): U = [i for i in range(n)] V = [i for i in range(m)] Pair_U = [n for u in U] Pair_V = [n for v in V] Dist = [(0) for i in range(n + 1)] matching = 0 while BFS(Adj, Dist, Pair_U, Pair_V, U, V, n) == True: for u in U: if Pair_U[u] == n: if DFS(Adj, Dist, Pair_V, Pair_U, u, n) == True: matching += 1 return matching def getDistance(x, y, u, v): dx = x - u dy = y - v return dx * dx + dy * dy def addEdges(Adj, distances, lo, hi): for i in range(lo, hi + 1): dist, u, v = distances[i] Adj[v].add(u) def removeEdges(Adj, distances, lo, hi): for i in range(hi + 1, lo, -1): dist, u, v = distances[i] Adj[v].remove(u) def binarySearch(distances, Adj, n, m, k): low = 0 high = len(distances) - 1 mid = int((low + high) / 2) addEdges(Adj, distances, low, mid) while low <= high: HK = HopcroftKarp(Adj, n, m) if HK >= k: high = mid - 1 mid = int((low + high) / 2) removeEdges(Adj, distances, mid, high) else: low = mid + 1 mid = int((low + high) / 2) addEdges(Adj, distances, low, mid) print(distances[mid + 1][0]) def main(): n, m, k = map(int, input().rstrip().split(" ")) Adj = [set() for i in range(n)] bikers = [] distances = [] for i in range(n): x, y = map(int, input().rstrip().split(" ")) bikers.append([x, y]) for i in range(m): u, v = map(int, input().rstrip().split(" ")) for j in range(n): x, y = bikers[j] distances.append([getDistance(x, y, u, v), i, j]) distances = sorted(distances, key=lambda x: x[0]) binarySearch(distances, Adj, n, m, k) main()
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 EXPR FUNC_CALL VAR VAR VAR RETURN VAR VAR VAR FUNC_DEF IF VAR VAR FOR VAR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR NUMBER FOR VAR VAR IF VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR LIST VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR
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 instruct any biker to move towards any bike in the city. In order to minimize the time to start the race, Jack instructs the bikers in such a way that the first $\mbox{K}$ bikes are acquired in the minimum time. Every biker moves with a unit speed and one bike can be acquired by only one biker. A biker can proceed in any direction. Consider distance between bikes and bikers as Euclidean distance. Jack would like to know the square of required time to start the race as soon as possible. Input Format The first line contains three integers, $N$, $\mbox{M}$, and $\mbox{K}$, separated by a single space. The following $N$ lines will contain $N$ pairs of integers denoting the co-ordinates of $N$ bikers. Each pair of integers is separated by a single space. The next $\mbox{M}$ lines will similarly denote the co-ordinates of the $\mbox{M}$ bikes. Constraints $1\leq N\leq250$ $1\leq M\leq250$ $1\leq K\leq min(N,M)$ $0\leq x_i$, $y_i$ $\leq10$$7$ Output Format A single line containing the square of required time. Sample Input 3 3 2 0 1 0 2 0 3 100 1 200 2 300 3 Sample Output 40000 Explanation There's need for two bikers for the race. The first biker (0,1) will be able to reach the first bike (100,1) in 100 time units. The second biker (0,2) will be able to reach the second bike (200,2) in 200 time units. This is the most optimal solution and will take 200 time units. So output will be 200^{2} = 40000.
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: del pred[matching[v]] layer = list(pred) while layer and not unmatched: newLayer = {} for u in layer: for v in graph[u]: if v not in preds: newLayer.setdefault(v, []).append(u) layer = [] for v in newLayer: preds[v] = newLayer[v] if v in matching: layer.append(matching[v]) pred[matching[v]] = v else: unmatched.append(v) if not unmatched: unlayered = {} for u in graph: for v in graph[u]: if v not in preds: unlayered[v] = None return matching, list(pred), list(unlayered) def recurse(v): if v in preds: L = preds[v] del preds[v] for u in L: if u in pred: pu = pred[u] del pred[u] if pu is unmatched or recurse(pu): matching[v] = u return 1 return 0 for v in unmatched: recurse(v) def main(): N, M, K = map(int, input().split()) bikers = [] bikes = [] for i in range(N): a, b = map(int, input().split()) bikers.append((a, b)) for i in range(M): a, b = map(int, input().split()) bikes.append((a, b)) edges = [] for a, b in bikers: for c, d in bikes: dist = (a - c) ** 2 + (b - d) ** 2 edges.append((dist, (a, b), (c, d))) edges = sorted(edges, reverse=True) removed_bikers = 0 removed_bikes = 0 biker_hits = dict([(biker, 0) for biker in bikers]) bike_hits = dict([(bike, 0) for bike in bikes]) bikers = set(bikers) bikes = set(bikes) neighbors = dict([(biker, set([bike for bike in bikes])) for biker in bikers]) G = dict([(biker, neighbors[biker]) for biker in bikers]) matching, A, B = bipartiteMatch(G) matching_pairs = set([(bike, matching[bike]) for bike in matching]) for dist, biker, bike in edges: biker_hits[biker] += 1 bike_hits[bike] += 1 neighbors[biker].remove(bike) if (bike, biker) in matching_pairs: G = dict([(biker, neighbors[biker]) for biker in bikers]) matching, A, B = bipartiteMatch(G) matching_pairs = set([(bike, matching[bike]) for bike in matching]) if len(matching.keys()) < K: print(dist) break if biker_hits[biker] == M: bikers.remove(biker) main()
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 VAR LIST VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR ASSIGN VAR DICT FOR VAR VAR FOR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR NONE RETURN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR VAR ASSIGN VAR VAR VAR VAR VAR FOR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR IF VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FOR VAR VAR VAR VAR VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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, c) print(len(ans)) print(*ans)
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 FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(arr) print(count) for i in arr: print(i, end=" ")
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_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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)) print(" ".join(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 VAR BIN_OP NUMBER NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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: if l < 10**9: an.append(l) if len(an) == 0: print(0) else: print(len(an)) print(*an)
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 VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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) == 0: print(0) quit() print(len(res)) print(" ".join(map(str, 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 IF VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(" ".join(map(str, r)))
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 FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 FUNC_CALL FUNC_CALL VAR VAR STRING STRING NUMBER NUMBER STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 > 0: ans.append(y) print(len(ans)) if len(ans) != 0: for _ in range(0, len(ans)): print(ans[_], end=" ") print("")
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 ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 LIST VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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] print(n) if n != 0: tab.sort() for i in range(len(tab)): print(tab[i], end=" ") print() main()
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 IF NUMBER VAR NUMBER FUNC_CALL VAR VAR VAR VAR NUMBER VAR LIST VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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, 82): z = b * power(t, a) + c if z > 0 and z < 1000000000: if sum_d(z) == t: ans.append(z) cnt += 1 print(cnt) print(*ans)
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 VAR LIST ASSIGN VAR NUMBER 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 IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 and chk and lis[i] > 0: ans.append(lis[i]) op = "" for i in range(len(ans)): op += str(ans[i]) + " " print(len(ans)) if len(op) > 0: print(op)
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 ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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)) print(" ".join(map(str, sorted(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 NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 = anss + [str(N**a * b + c)] print(len(anss)) if len(anss) != 0: print(" ".join(anss))
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_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP NUMBER NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR LIST FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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)) print(len(arr)) print(" ".join(arr))
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 FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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) print(len(ans)) if ans: print(" ".join(map(str, ans))) def main(): a, b, c = map(int, input().split()) find_X(a, b, c) main()
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 VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 arr: print(x, end=" ")
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 BIN_OP NUMBER NUMBER IF FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
__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) for i in ans: print(i, end=" ")
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_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(map(str, ret))))
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 VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR FUNC_CALL STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(*sol)
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 ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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.append(y) if len(fin) == 0: print("0") else: print(count) for i in range(count): print(fin[i], end=" ")
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 FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(*ans)
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 FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(*ar)
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 FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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: print(i, end=" ") a, b, c = map(int, input().split()) s(a, b, c)
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 ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(map(str, sorted(res)))) main()
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 EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL VAR VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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): inputs = input().strip() if mode == 0: return inputs if mode == 1: return inputs.split() if mode == 2: return list(map(int, inputs.split())) def write(s="\n"): if s is None: s = "" if isinstance(s, list): s = " ".join(map(str, s)) s = str(s) print(s, end="") write(main())
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_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_DEF NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN FUNC_CALL VAR IF VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_DEF STRING IF VAR NONE ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 NUMBER NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR VAR LIST FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 = b * power(sm, a) + c if 0 < num < 10**9 and digitsum(num) == sm: count += 1 val.append(num) print(count) for no in val: print(no, end=" ")
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 VAR LIST 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 NUMBER FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 ** self.a_b_c[0] + self.a_b_c[2] if 0 < sol <= 10**9 + 1: if sum([int(x) for x in str(sol)]) == y: solutions.add(sol) solutions = sorted(list(solutions)) self.result = "{0}\n{1}".format( len(solutions), " ".join([str(x) for x in solutions]) ) def get_result(self): return self.result Solution = CodeforcesTask460BSolution() Solution.read_input() Solution.process_task() print(Solution.get_result())
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 FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR FUNC_DEF RETURN VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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**9: ans.add(cnt) ans = list(ans) ans.sort() print(len(ans)) print(*ans)
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 IF VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(pos) print(" ".join(list(map(str, A[:pos]))))
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_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 else: x = x // 10 + 1 return s ans = [] count = 0 for i in range(1, 82): val = b * power(i, a) + c if sm(val) == i and 0 < val < 1000000000: ans.append(val) count += 1 print(count) print(*ans)
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 ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 in ans: print(i, end=" ")
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 FUNC_CALL VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 STRING VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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: solutions.append(x) print(len(solutions)) if len(solutions) != 0: print(" ".join(map(str, solutions))) main()
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 VAR NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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: print(*lol)
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 FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 result_val = check_if_valid_res(approx_res, i) if result_val: solutions.append(approx_res) if len(solutions) > 0: final_res = [] for i in range(len(solutions)): if solutions[i] > 0 and solutions[i] < pow(10, 9): final_res.append(solutions[i]) print(len(final_res)) print(*final_res) else: print(0)
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 VAR FUNC_CALL VAR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR LIST 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(" ".join(map(str, solutions)))
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 EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 STRING FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(ans)) for i in ans: print(i, end=" ")
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_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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=" ")
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 NUMBER VAR BIN_OP NUMBER NUMBER BIN_OP BIN_OP VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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: tem = list(str(x)) summ = 0 for t in tem: summ += int(t) if x == sign * (b * summ**a + c): realx.append(x) length = len(realx) print(length) if length > 0: print(*realx) k(a, b, c)
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 VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 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 VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 NUMBER VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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() for i in range(1, 82): x = B * power(i, A) + C if 0 < x < 10**9 and i == sum_numbers(x): result.append(x) return result c, d, e = [int(j) for j in input().split()] print(len(reshenie(c, d, e))) print(*reshenie(c, d, e))
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 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 NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 NUMBER FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(ans)) print(*ans)
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_OP VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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_CALL VAR VAR FUNC_CALL STRING VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(l)) print(*l)
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 VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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: print(*sol)
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 EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 > 0 and i < 1000000000: l2.append(i) print(len(l2)) for i in l2: print(i, end=" ")
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_OP BIN_OP VAR BIN_OP VAR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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) print(len(ans)) print(*ans)
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 BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP NUMBER NUMBER BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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: if num > 0: if sum_of_digs(num) == i: sol.append(num) j += 1 print(j) if j > 0: w = 1 while w <= j: print(sol[w - 1], end=" ") w += 1
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 VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR VAR IF VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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): temp = c + b * j**a if sumn(temp, j, i): if temp != 0: l.append(temp) print(len(l)) if len(l) > 0: print(*l)
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 BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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.append(num) print(len(track)) print(" ".join(map(str, track))) a, b, c = map(int, input().split()) solve(a, b, c)
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 VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING
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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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(str(x)) n = len(values) salida = " ".join(values) print(n) if n > 0: print(salida)
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_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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 x > 0 and x < 10**9: ans.append(int(x)) print(len(ans)) for x in ans: print(x, end=" ") main()
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 VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING 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 in the decimal representation of number x. The teacher gives this problem to Dima for each lesson. He changes only the parameters of the equation: a, b, c. Dima got sick of getting bad marks and he asks you to help him solve this challenging problem. -----Input----- The first line contains three space-separated integers: a, b, c (1 ≤ a ≤ 5; 1 ≤ b ≤ 10000;  - 10000 ≤ c ≤ 10000). -----Output----- Print integer n — the number of the solutions that you've found. Next print n integers in the increasing order — the solutions of the given equation. Print only integer solutions that are larger than zero and strictly less than 10^9. -----Examples----- Input 3 2 8 Output 3 10 2008 13726 Input 1 2 -18 Output 0 Input 2 2 -1 Output 4 1 31 337 967
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] = n i += 1 print(i) j = 0 while i > j: print(c1[j], end=" ") j += 1
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 BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING VAR NUMBER