description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | from sys import stdin
input = stdin.readline
n, k = map(int, input().split())
a = list(map(int, input().split()))
vals = [[] for i in range(2 * 10**5 + 1)]
b = [a[i] for i in range(n)]
s = set()
for i in range(n):
cnt = 0
while b[i] > 0:
s.add(b[i])
vals[b[i]].append(cnt)
b[i] //= 2
cnt += 1
s = list(s)
ans = 10**18
for x in s:
vals[x].sort()
if len(vals[x]) >= k:
ans = min(ans, sum(vals[x][:k]))
print(ans) | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | from itertools import islice
_, k = tuple(map(int, input().split()))
arr = list(map(int, input().split()))
counts = [None] * (2 * 10**5 + 1)
def append_counts(xx, cnt):
if counts[xx] is None:
counts[xx] = []
counts[xx].append(cnt)
for a in arr:
cur = 0
x = a
while x > 0:
append_counts(x, cur)
x //= 2
cur += 1
result = 2 * 10**7
for i in counts:
if i and len(i) >= k:
i.sort()
result = min(result, sum(islice(i, 0, k)))
print(result) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER FUNC_DEF IF VAR VAR NONE ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
G = []
for _ in range(2 * 10**5 + 100):
G.append([])
c = 0
for i in A:
if len(G[i]) < k:
G[i].append(0)
while True:
c += 1
f = True
for i in range(n):
if A[i]:
A[i] //= 2
if len(G[A[i]]) < k:
G[A[i]].append(c)
if A[i]:
f = False
if f:
break
ans = 10**9
for t in G:
if len(t) == k:
ans = min(ans, sum(t))
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER WHILE NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()
d = {}
for i in range(len(a)):
temp = a[i]
curr = 0
while temp:
if temp not in d or d[temp][0] < k:
if temp in d:
d[temp][0] += 1
d[temp][1] += curr
else:
d[temp] = [1, curr]
curr += 1
temp = temp >> 1
ans = 10000000000000000
for i in d:
if d[i][0] >= k:
ans = min(ans, d[i][1])
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR IF VAR VAR VAR VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER NUMBER VAR VAR NUMBER VAR ASSIGN VAR VAR LIST NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | import sys
n, k = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
xs = [0]
for i in range(n):
x = a[i]
while x != 0:
xs.append(x)
x = x // 2
xs = list(set(xs))
op_cnts = dict()
for x in xs:
op_cnts[x] = []
for i in range(n):
cnt = 0
start = a[i]
while True:
if start in op_cnts:
op_cnts[start].append(cnt)
cnt += 1
if start == 0:
break
start = start // 2
minVal = sys.maxsize
for x in xs:
if len(op_cnts[x]) >= k:
op_cnts[x] = sorted(op_cnts[x])
for x in xs:
if len(op_cnts[x]) >= k:
sumVal = 0
for j in range(k):
sumVal += op_cnts[x][j]
minVal = min(minVal, sumVal)
print(minVal) | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
vals = [[] for i in range(200 * 1000 + 11)]
for i in a:
cur = 0
x = i
while x > 0:
vals[x].append(cur)
cur += 1
x //= 2
answer = 1000000000
for i in range(200 * 1000):
vals[i].sort()
if len(vals[i]) < k:
continue
answer = min(answer, sum(vals[i][:k]))
print(answer) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | n, k = [int(i) for i in input().split()]
a = sorted([int(i) for i in input().split()])
numbers = [[0, 0] for i in range(a[-1] + 1)]
for i in range(n):
op = 0
while a[i] > 0:
if numbers[a[i]][0] < k:
numbers[a[i]][0] += 1
numbers[a[i]][1] += op
a[i] //= 2
op += 1
numbers[0][0] += 1
numbers[0][1] += op
ans = numbers[0][1]
for number in numbers:
if number[0] >= k and number[1] < ans:
ans = number[1]
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR VAR VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER NUMBER NUMBER VAR NUMBER NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | def get_ans(n, k, array):
logging = {(0): []}
for i in array:
steps = 0
temp = i
while temp > 0:
if temp not in logging.keys():
logging[temp] = [steps]
else:
logging[temp].append(steps)
temp = temp // 2
steps += 1
logging[0].append(steps)
ans = sum(logging[0])
for key, values in logging.items():
if len(values) >= k:
temp_ans = sum(sorted(values)[0:k])
if temp_ans < ans:
ans = temp_ans
return ans
n, k = list(map(int, input().strip().split()))
array = list(map(int, input().strip().split()))
print(get_ans(n, k, array)) | FUNC_DEF ASSIGN VAR DICT NUMBER LIST FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER IF VAR FUNC_CALL VAR ASSIGN VAR VAR LIST VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | def deep(mas, pref, k):
deepmas = []
s = 0
for el in mas:
if el[: len(pref)] == pref:
deepmas.append(el)
if len(deepmas) <= k:
s += len(el) - len(pref)
if len(deepmas) >= k:
return min(s, deep(deepmas, pref + "0", k), deep(deepmas, pref + "1", k))
else:
return 20000000000000000
n, k = map(int, input().split())
mas = list(map(int, input().split()))
mas.sort()
mas = list(map(bin, mas))
pref = "0b"
ans = deep(mas, pref, k)
print(ans) | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR STRING VAR FUNC_CALL VAR VAR BIN_OP VAR STRING VAR RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | from sys import stdin
input = stdin.readline
n, k = map(int, input().split())
arr = [*map(int, input().split())]
cnt = [(0) for i in range(200001)]
for i in range(n):
cnt[arr[i]] += 1
arr.sort()
p = [[] for i in range(200001)]
for i in range(n):
t = 1
while arr[i]:
arr[i] //= 2
p[arr[i]].append(t)
t += 1
ans = 1e18
for i in range(200001):
if cnt[i] + len(p[i]) >= k:
ans = min(ans, sum(p[i][: max(0, k - cnt[i])]))
print(ans) | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | from sys import stdin
input = stdin.readline
inf = 1000 * 1000 * 1000
n, k = list(map(int, input().split()))
a = [int(i) for i in input().split()]
b = []
for i in range(200001):
b.append([])
for i in a:
ctr = 0
while i > 0:
b[i].append(ctr)
i //= 2
ctr += 1
b[i].append(ctr)
res = inf
for i in b:
if len(i) >= k:
i.sort()
tmp = 0
for j in range(k):
tmp += i[j]
res = min(res, tmp)
print(res) | ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
cnt = dict()
sum = dict()
res = n * 20
for x in a:
y = x
cur = 0
while True:
if y == 0:
break
if y not in cnt:
cnt[y] = 0
sum[y] = 0
if cnt[y] < k:
cnt[y] += 1
sum[y] += cur
if cnt[y] == k:
res = min(res, sum[y])
y >>= 1
cur += 1
print(res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | def mp():
return map(int, input().split())
def f(a, b):
res = 0
while b > a:
b //= 2
res += 1
if b != a:
res = -1
return res
n, k = mp()
a = sorted(list(mp()))
m = max(a) + 1
b = [0] * m
c = [0] * m
for i in a:
x = i
cnt = 0
while x > 0:
if c[x] < k:
b[x] += cnt
c[x] += 1
x //= 2
cnt += 1
if c[0] < k:
b[0] += cnt
c[0] += 1
ans = b[0]
for i in range(1, m):
if c[i] == k:
ans = min(ans, b[i])
print(ans) | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | import sys
input = sys.stdin.readline
MOD = 1000000007
MOD2 = 998244353
ii = lambda: int(input().strip("\n"))
si = lambda: input().strip("\n")
dgl = lambda: list(map(int, input().strip("\n")))
f = lambda: map(int, input().strip("\n").split())
il = lambda: list(map(int, input().strip("\n").split()))
ls = lambda: list(input().strip("\n"))
lsi = lambda: [int(i) for i in ls()]
let = "abcdefghijklmnopqrstuvwxyz"
for _ in range(1):
n, k = f()
l = il()
mx = max(l)
cost = [[] for i in range(mx + 1)]
for i in l:
x = 0
while i > 0:
cost[i].append(x)
x += 1
i //= 2
cost[0].append(x)
mn = 10**15
for i in range(mx + 1):
if len(cost[i]) >= k:
cost[i].sort()
mn = min(mn, sum(cost[i][:k]))
print(mn) | IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | from sys import stdin
def input():
return next(stdin)
def main():
n, k = map(int, input().split())
aa = [int(a) for a in input().split()]
aa.sort()
valmap = [[0, 0] for _ in range(200001)]
for a in aa:
if add_to_map(a, 0, k, valmap):
i = 0
while a > 0:
i += 1
a = a // 2
if not add_to_map(a, i, k, valmap):
break
result = min(s for c, s in valmap if c == k)
print(result)
def add_to_map(a, i, k, valmap):
if valmap[a][0] < k:
valmap[a][0] += 1
valmap[a][1] += i
return True
else:
return False
main() | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF IF VAR VAR NUMBER VAR VAR VAR NUMBER NUMBER VAR VAR NUMBER VAR RETURN NUMBER RETURN NUMBER EXPR FUNC_CALL VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | from sys import stdin, stdout
input = stdin.readline
t = 1
for _ in range(t):
n, p = map(int, input().split())
a = [int(x) for x in input().split()]
vals = set()
dict = {}
for i in a:
k = 0
while i:
if i in dict:
dict[i].append(k)
else:
dict[i] = [k]
vals.add(i)
i //= 2
k += 1
ans = float("inf")
for i in dict:
if len(dict[i]) >= p:
ans = min(ans, sum(sorted(dict[i])[:p]))
print(ans) | ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | def main():
(n, m), d = map(int, input().split()), {}
for i in map(int, input().split()):
t = 0
while i:
d.setdefault(i, [1000000000]).append(t)
i >>= 1
t += 1
print(min(sum(sorted(v)[:m]) for v in d.values()))
main() | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR DICT FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR EXPR FUNC_CALL FUNC_CALL VAR VAR LIST NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | n, k = map(int, input().split())
s = [int(x) for x in input().split()]
kk = []
uni = dict()
for i in range(0, len(s)):
N = 2 * s[i]
c = -1
while N > 0:
c += 1
N = N // 2
if uni.get(N) == None:
uni[N] = [c]
kk.append(N)
else:
uni[N].append(c)
ans = 20 * n
for i in kk:
l = uni[i]
if len(l) >= k:
l = sorted(l)
sumu = 0
for j in range(k):
sumu += l[j]
ans = min(ans, sumu)
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NONE ASSIGN VAR VAR LIST VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR FOR VAR VAR ASSIGN VAR VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | def main():
n, m = map(int, input().split())
aa, bb = [m] * 200001, [0] * 200001
for i in sorted(map(int, input().split())):
aa[i] -= 1
t = 0
while i:
t += 1
i //= 2
if aa[i] <= 0:
continue
aa[i] -= 1
bb[i] += t
print(min(b for a, b in zip(aa, bb) if a <= 0))
main() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST VAR NUMBER BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR |
The only difference between easy and hard versions is the number of elements in the array.
You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$).
You can perform such an operation any (possibly, zero) number of times with any $a_i$.
Your task is to calculate the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
Don't forget that it is possible to have $a_i = 0$ after some operations, thus the answer always exists.
-----Input-----
The first line of the input contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) — the number of elements in the array and the number of equal numbers required.
The second line of the input contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2 \cdot 10^5$), where $a_i$ is the $i$-th element of $a$.
-----Output-----
Print one integer — the minimum possible number of operations required to obtain at least $k$ equal numbers in the array.
-----Examples-----
Input
5 3
1 2 2 4 5
Output
1
Input
5 3
1 2 3 4 5
Output
2
Input
5 3
1 2 3 3 3
Output
0 | n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
out = 10000000000 + 7
d = [[] for i in range(0, max(l) + 1)]
if k != 1:
for i in l:
c = 0
while i:
d[i].append(c)
c += 1
i //= 2
for i in d:
if len(i) >= k:
out = min(out, sum(i[:k]))
print(out)
else:
print(0) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER |
A monster is attacking the Cyberland!
Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF).
During the battle, every second the monster's HP decrease by max(0, ATK_{Y} - DEF_{M}), while Yang's HP decreases by max(0, ATK_{M} - DEF_{Y}), where index Y denotes Master Yang and index M denotes monster. Both decreases happen simultaneously Once monster's HP ≤ 0 and the same time Master Yang's HP > 0, Master Yang wins.
Master Yang can buy attributes from the magic shop of Cyberland: h bitcoins per HP, a bitcoins per ATK, and d bitcoins per DEF.
Now Master Yang wants to know the minimum number of bitcoins he can spend in order to win.
-----Input-----
The first line contains three integers HP_{Y}, ATK_{Y}, DEF_{Y}, separated by a space, denoting the initial HP, ATK and DEF of Master Yang.
The second line contains three integers HP_{M}, ATK_{M}, DEF_{M}, separated by a space, denoting the HP, ATK and DEF of the monster.
The third line contains three integers h, a, d, separated by a space, denoting the price of 1 HP, 1 ATK and 1 DEF.
All numbers in input are integer and lie between 1 and 100 inclusively.
-----Output-----
The only output line should contain an integer, denoting the minimum bitcoins Master Yang should spend in order to win.
-----Examples-----
Input
1 2 1
1 100 1
1 100 100
Output
99
Input
100 100 100
1 1 1
1 1 1
Output
0
-----Note-----
For the first sample, prices for ATK and DEF are extremely high. Master Yang can buy 99 HP, then he can beat the monster with 1 HP left.
For the second sample, Master Yang is strong enough to beat the monster, so he doesn't need to buy anything. | hy, ay, dy = map(int, input().split())
hm, am, dm = map(int, input().split())
h, a, d = map(int, input().split())
s = 1 << 30
for da in range(max(0, dm - ay + 1), max(0, hm - ay + dm) + 1):
for dd in range(max(0, am - dy) + 1):
dh = max(0, (am - dy - dd) * ((hm - 1) // (ay + da - dm) + 1) - hy + 1)
s = min(s, h * dh + a * da + d * dd)
print(s) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
A monster is attacking the Cyberland!
Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF).
During the battle, every second the monster's HP decrease by max(0, ATK_{Y} - DEF_{M}), while Yang's HP decreases by max(0, ATK_{M} - DEF_{Y}), where index Y denotes Master Yang and index M denotes monster. Both decreases happen simultaneously Once monster's HP ≤ 0 and the same time Master Yang's HP > 0, Master Yang wins.
Master Yang can buy attributes from the magic shop of Cyberland: h bitcoins per HP, a bitcoins per ATK, and d bitcoins per DEF.
Now Master Yang wants to know the minimum number of bitcoins he can spend in order to win.
-----Input-----
The first line contains three integers HP_{Y}, ATK_{Y}, DEF_{Y}, separated by a space, denoting the initial HP, ATK and DEF of Master Yang.
The second line contains three integers HP_{M}, ATK_{M}, DEF_{M}, separated by a space, denoting the HP, ATK and DEF of the monster.
The third line contains three integers h, a, d, separated by a space, denoting the price of 1 HP, 1 ATK and 1 DEF.
All numbers in input are integer and lie between 1 and 100 inclusively.
-----Output-----
The only output line should contain an integer, denoting the minimum bitcoins Master Yang should spend in order to win.
-----Examples-----
Input
1 2 1
1 100 1
1 100 100
Output
99
Input
100 100 100
1 1 1
1 1 1
Output
0
-----Note-----
For the first sample, prices for ATK and DEF are extremely high. Master Yang can buy 99 HP, then he can beat the monster with 1 HP left.
For the second sample, Master Yang is strong enough to beat the monster, so he doesn't need to buy anything. | h1, a1, d1 = map(int, input().split(" "))
h2, a2, d2 = map(int, input().split(" "))
H, A, D = map(int, input().split(" "))
ans = 100000000
for a in range(a1, 201):
if a - d2 <= 0:
continue
for d in range(d1, 102):
if a2 - d <= 0:
ans = min(ans, (a - a1) * A + (d - d1) * D)
else:
turn = h2 // (a - d2) + (h2 % (a - d2) > 0)
h = max(0, a2 - d) * turn + 1
h = max(h, h1)
ans = min(ans, (h - h1) * H + (a - a1) * A + (d - d1) * D)
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR |
A monster is attacking the Cyberland!
Master Yang, a braver, is going to beat the monster. Yang and the monster each have 3 attributes: hitpoints (HP), offensive power (ATK) and defensive power (DEF).
During the battle, every second the monster's HP decrease by max(0, ATK_{Y} - DEF_{M}), while Yang's HP decreases by max(0, ATK_{M} - DEF_{Y}), where index Y denotes Master Yang and index M denotes monster. Both decreases happen simultaneously Once monster's HP ≤ 0 and the same time Master Yang's HP > 0, Master Yang wins.
Master Yang can buy attributes from the magic shop of Cyberland: h bitcoins per HP, a bitcoins per ATK, and d bitcoins per DEF.
Now Master Yang wants to know the minimum number of bitcoins he can spend in order to win.
-----Input-----
The first line contains three integers HP_{Y}, ATK_{Y}, DEF_{Y}, separated by a space, denoting the initial HP, ATK and DEF of Master Yang.
The second line contains three integers HP_{M}, ATK_{M}, DEF_{M}, separated by a space, denoting the HP, ATK and DEF of the monster.
The third line contains three integers h, a, d, separated by a space, denoting the price of 1 HP, 1 ATK and 1 DEF.
All numbers in input are integer and lie between 1 and 100 inclusively.
-----Output-----
The only output line should contain an integer, denoting the minimum bitcoins Master Yang should spend in order to win.
-----Examples-----
Input
1 2 1
1 100 1
1 100 100
Output
99
Input
100 100 100
1 1 1
1 1 1
Output
0
-----Note-----
For the first sample, prices for ATK and DEF are extremely high. Master Yang can buy 99 HP, then he can beat the monster with 1 HP left.
For the second sample, Master Yang is strong enough to beat the monster, so he doesn't need to buy anything. | I = lambda: list(map(int, input().split()))
R = list(range(999))
q, w, e = I()
r, t, y = I()
a, b, c = I()
print(
min(
i * b
+ j * c
+ max(0, (r // (w + i - y) + bool(r % (w + i - y))) * (t - e - j) - q + 1) * a
for i in R
for j in R
if w + i > y
)
) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | def main():
t = int(input())
for _ in range(t):
n = int(input())
prev = -1
ans = []
for i in range(1, 40000):
v = n // i
if v == prev:
break
ans.append(v)
prev = v
for i in range(v - 1, -1, -1):
ans.append(i)
print(len(ans))
print(*ans[::-1])
def __starting_point():
main()
__starting_point() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
a = set()
k = n**0.5
for i in range(1, int(k) + 1):
a.add(i)
a.add(n // i)
a.add(0)
print(len(a))
print(*sorted(list(a))) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
mid = int(n**0.5)
if n // mid > mid:
print(2 * mid + 1)
else:
print(2 * mid)
i = 0
while i <= mid:
print(i, end=" ")
i += 1
i = mid
while i > 0:
if n // i > mid:
print(n // i, end=" ")
i -= 1
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR STRING VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | import sys
reader = (int(s.rstrip()) for s in sys.stdin)
def rating(n):
m = n
ans = [0, 1]
ndiv = 2
while True:
brick = n // ndiv
if not brick:
break
ndiv = n // brick
ans.append(ndiv)
ndiv += 1
return ans
t = next(reader)
for _ in range(t):
n = next(reader)
ans = rating(n)
sys.stdout.write(str(len(ans)) + "\n")
sys.stdout.write(" ".join(map(str, ans)) + "\n") | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL STRING FUNC_CALL VAR VAR VAR STRING |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in [0] * int(input()):
n = int(input())
a = [i for i in range(int(n ** (1 / 2) + 1))] + [
int(n / i) for i in range(1, int(n ** (1 / 2) + 1))
]
a = sorted(list(set(a)))
print(len(a))
print(" ".join([str(x) for x in a])) | FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | q = int(input())
for _ in range(q):
w = int(input())
e = [1]
for i in range(2, int(w**0.5) + 1):
if w // e[-1] != w // i:
e.append(i)
r = []
for i in range(len(e)):
r.append(w // e[i])
e = set(e + r + [0])
print(len(e))
print(*sorted(e)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR LIST NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
lis = []
i = n + 1
while i > 0:
a = n // i
lis.append(a)
i = n // (a + 1)
print(len(lis))
print(*lis) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | from sys import stdin
def iin():
return int(stdin.readline())
def lin():
return list(map(int, stdin.readline().split()))
def check(a):
sa = set()
for i in range(a + 1, 0, -1):
sa.add(a // i)
return sa
def main():
t = iin()
while t:
t -= 1
n = iin()
ans = {0}
ch = 1
while 1:
x = n // ch
if x == 0:
break
ch = n // x
ans.add(ch)
ch += 1
ans.add(n)
ans = list(ans)
ans.sort()
print(len(ans))
print(*ans)
main() | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR 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 EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for qwertyuiop in range(int(input())):
n = int(input())
q = set()
for i in range(1, 2 * int(n**0.5) + 7):
q.add(n // i)
q.add(n // (n // i + 1))
q.add(0)
print(len(q))
print(*sorted(list(q))) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for i in range(int(input())):
n = int(input())
s = set([0, n])
for j in range(int(n**0.5)):
s.add(n // (j + 1))
s.add(j + 1)
print(len(s))
print(*sorted(s)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
aaa = set()
aaa.add(0)
for i in range(1, int(n**0.5) + 1):
aaa.add(n // i)
aaa.add(i)
print(len(aaa))
print(*sorted(aaa)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | tst = int(input())
for i in range(0, tst):
n = int(input())
ans = 1
l = 1
p = []
while l <= n:
ans += 1
l = n // (n // l)
p.append(n // l)
l += 1
p.append(0)
p.reverse()
print(len(p))
print(" ".join(str(x) for x in p)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR 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 VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for tc in range(int(input())):
n = int(input())
i = 1
S = {0}
while i * i <= n:
S.add(n // i)
if i > n % i:
S.add(i)
i += 1
print(len(S))
for x in sorted(S):
print(x) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | import sys
input = lambda: sys.stdin.readline().rstrip()
for _ in range(int(input())):
n = int(input())
s = set([0])
for i in range(1, int(n**0.5) + 1):
v = n // i
s.add(v)
s.add(i)
print(len(s))
print(*sorted(s)) | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
i = 1
also = []
sqrN = int(n**0.5)
while n // i > sqrN:
also.append(n // i)
i += 1
also.reverse()
print(int(n**0.5) + len(also) + 1)
for i in range(sqrN + 1):
print(i, end=" ")
for d in also:
print(d, end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
k = int(n**0.5)
b = [0]
for i in range(1, k + 1):
b.append(i)
b.append(n // i)
b = list(set(b))
print(len(b))
print(*sorted(b)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
if n == 1:
print(2)
print(0, 1)
else:
k = int(n**0.5)
b = set(range(0, k + 1))
for i in range(k, 1, -1):
b.add(n // i)
b.add(n)
b = sorted(list(b))
print(len(b))
print(" ".join(map(str, b))) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | def print_seq(n):
t = n + 1
pi = n - 1
ls = []
ls.append("0")
ls.append("1")
i = n // 2
while i > 1:
t = n // i
ls.append(str(t))
i = n // (n // i + 1)
if n != 1:
ls.append(str(n))
print(len(ls))
print(" ".join(ls))
return
def main():
t = int(input())
for _ in range(t):
n = int(input())
print_seq(n)
main() | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR 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 RETURN FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
lst = [i for i in range(1, int(n ** (1 / 2) + 1))]
r = [str(elem) for elem in sorted(list(set(lst + [(n // i) for i in lst])))]
print(len(r) + 1)
print(
0,
" ".join(
[str(elem) for elem in sorted(list(set(lst + [(n // i) for i in lst])))]
),
) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | T = int(input())
for t in range(T):
N = int(input())
V = {0}
A = [0]
for i in range(1, int(N**0.5) + 1):
if i not in V:
A.append(i)
V.add(i)
if N // i not in V:
A.append(N // i)
V.add(N // i)
print(len(A))
print(*sorted(A)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for _ in range(t):
n = int(input())
l = [0, n]
k = 1
ans = 1
last = n
while k < n:
k += 1
if n // k == last:
k = n // last
else:
ans += 1
last = n // k
l.append(last)
l.sort()
print(len(l))
print(*l) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
l = set()
l.add(0)
for i in range(1, int(pow(n, 0.5)) + 10):
t = n // i
l.add(t)
if t != 0:
l.add(n // t)
l = sorted(list(l))
print(len(l))
print(*l) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | def kek(n):
l = [0]
l2 = []
i = 1
while i * i < n:
l.append(i)
if n // i != i:
l2.append(n // i)
i += 1
if i * i == n:
l.append(i)
l2.reverse()
l += l2
return l
def main():
for _ in range(int(input())):
n = int(input())
l = kek(n)
print(len(l))
for i in l:
print(i, end=" ")
print()
main() | FUNC_DEF ASSIGN VAR LIST NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | def solve():
n = int(input().strip())
sqrt = int(n**0.5)
ar = []
for i in range(sqrt + 1):
ar.append(i)
if n // sqrt != sqrt:
ar.append(n // sqrt)
for i in range(sqrt - 1, 0, -1):
ar.append(n // i)
print(len(ar))
print(" ".join(list(map(str, ar))))
t = int(input().strip())
for _ in range(t):
solve() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for _ in range(t):
n = int(input())
s = set([])
for i in range(1, int(n**0.5) + 1):
if n // i != 0:
s.add(int(n / i))
s.add(i)
s.add(0)
l = list(s)
l.sort()
print(len(l))
print(*l) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for _ in range(t):
n = int(input())
k = 1
ans = {0}
while k <= n:
ys = n // k
t = n // ys
ans.add(t)
k = t + 1
print(len(ans))
print(*ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
a = []
d = {}
for i in range(1, int(n**0.5 + 1)):
if i not in d.keys():
a.append(i)
d[i] = 1
if n // i not in d.keys():
a.append(n // i)
d[n // i] = 1
a.sort()
print(len(a) + 1)
print(0, end=" ")
for i in a:
print(i, end=" ")
print("") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
s = set()
s.add(0)
i = 1
while i * i <= n:
s.add(i)
s.add(n // i)
i += 1
print(len(s))
print(*sorted(list(s))) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
k = set()
a = 1
b = n // a
listrating = set([0])
while a < b:
listrating.add(n // a)
listrating.add(n // b)
a += 1
b = n // a
listrating.add(n // a)
listrating.add(n // b)
listrating = list(listrating)
listrating.sort()
print(len(listrating))
print(" ".join([str(x) for x in listrating])) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR LIST NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR 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 VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
l1 = []
a = n
for i in range(1, int(n**0.5) + 1):
a = n // i
l1.append(a)
if n == (int(n**0.5) + 1) ** 2 - 1:
a -= 1
while a:
a -= 1
l1.append(a)
print(len(l1))
l1.reverse()
for i in l1:
print(i, end=" ")
print("") | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER VAR NUMBER WHILE VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR STRING |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | def solve():
n = int(input())
s = int(n**0.5)
ans = {0}
for i in range(1, s + 1):
ans.add(i)
ans.add(n // i)
ans.add(n)
print(len(ans))
print(" ".join([str(el) for el in sorted(ans)]))
for _ in range(int(input())):
solve() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP 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 VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for _ in range(t):
vis = set()
s = set()
n = int(input())
for i in range(1, int(n**0.5) + 2):
if n // i not in vis:
vis.add(n // i)
s.add(n // i)
res = sorted(s)
res = list(range(res[0] - 1, -1, -1))[::-1] + res
print(len(res))
print(*res) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
if n <= 1000005:
l = [0, 1]
for k in range(n - 1, 0, -1):
a = n // k
if a > l[-1]:
l.append(a)
print(len(l))
print(*l)
else:
l = [x for x in range(1001)]
for k in range(1000000, 0, -1):
a = n // k
if a > l[-1]:
l.append(a)
print(len(l))
print(*l) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
out = []
for i in range(t):
n = int(input())
out = ["0"]
start = n + 1
end = n
while start > 0 and end > 0 and int(n / start) != int(n / end):
out.append(str(int(n / end)))
start = int(n / int(n / end))
end = min(start - 1, int(n / (int(n / end) + 1)))
print(len(out))
print(" ".join(out)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for I in range(t):
n = int(input())
ans = [0] * 10**5
d = 1
count = 0
while d * d - 1 <= n:
ans[count] = n // d
d += 1
count += 1
d = ans[count - 1]
for i in range(d - 1, -1, -1):
ans[count] = i
count += 1
print(count)
print(" ".join([str(i) for i in list(reversed(ans[:count]))])) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | sp = lambda: list(map(int, input().split()))
si = lambda: int(input())
TESTCASES = int(input())
for tc in range(TESTCASES):
n = si()
ints = set(range(int(n**0.5) + 1))
for i in range(int(n**0.5) + 1, 0, -1):
ints.add(n // i)
ints = sorted(list(ints))
print(len(ints))
print(" ".join(map(str, ints))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for i in range(t):
n = int(input())
lst = [0]
for j in range(1, n + 1):
tmp = int(n // j)
lst.append(tmp)
if tmp * tmp <= n:
for k in range(tmp + 2):
if k * k <= n:
lst.append(k)
break
lst = list(set(lst))
lst.sort()
lst = [str(i) for i in lst]
print(len(lst))
print(" ".join(lst)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input().strip())
for i in range(t):
n = int(input().strip())
result = ["0", "1"]
it = 1
while it != n:
it += 1
m = n // it
it = n // m
result.append(str(it))
print(len(result))
print(" ".join(result)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST STRING STRING ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP 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 |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | from sys import stdin, stdout
casos = int(stdin.readline().strip())
for case in range(casos):
n = int(stdin.readline().strip())
x = int(pow(n, 0.5))
ans = [i for i in range(x + 1)]
for i in range(x, 0, -1):
y = n // i
if y != ans[-1]:
ans.append(y)
stdout.write("%d\n" % len(ans))
print(*ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
while t != 0:
n = int(input())
list1 = [0]
i = 1
while i <= n:
p = n // i
if n // p == i:
list1.append(i)
i += 1
else:
list1.append(n // p)
i = n // p + 1
print(len(list1))
print(*list1)
t -= 1 | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for _ in range(t):
n = int(input())
s = {0, 1}
for i in range(1, int(n**0.5) + 1):
k = n // i
b = n // k
s.add(k)
s.add(b)
print(len(s))
s2 = list(s)
s2.sort()
print(*s2) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | def bsearch(st, en, n, x):
k = (st + en) // 2
if n // k < x:
if st == en:
return k
return bsearch(st, k, n, x)
return bsearch(k + 1, en, n, x)
def solve():
n = int(input())
x = n
ans = [str(x)]
while x > 1:
k = bsearch(0, n, n, x)
x = n // k
ans.append(str(x))
ans.append("0")
print(len(ans))
print(" ".join(ans[::-1]))
for _ in range(int(input())):
solve() | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR IF VAR VAR RETURN VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
ls = {0}
for i in range(1, int(n**0.5) + 1):
ls.add(n // i)
ls.add(n // (n // i))
print(len(ls))
print(*sorted(ls)) | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | import sys
input = sys.stdin.readline
def main():
t = int(input())
for _ in range(t):
N = int(input())
ans = []
ans.append(0)
p = 0
pn = 0
for i in range(1, int(N**0.5) + 1):
x = N // i
if x != p and x != pn:
ans.append(x)
p = x
if i != pn and i != p:
ans.append(i)
pn = i
print(len(ans))
ans.sort()
print(*ans)
main() | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for you in range(t):
n = int(input())
l = []
i = 1
while i * i <= n:
if i == n // i:
l.append(i)
else:
l.append(i)
l.append(n // i)
i += 1
l.sort()
print(len(l) + 1)
print(0, end=" ")
for i in l:
print(i, end=" ")
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER STRING FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for i in range(t):
n = int(input())
answers = set()
answers.add(n)
x = 1
while x <= n // 2 + 1:
target = n // x
left = x
right = (n + 1) // target + 1
ans = x
while left <= right:
mid = (left + right) // 2
if n // mid == target:
ans = mid
left = mid + 1
else:
right = mid - 1
x = ans + 1
answers.add(n // x)
answers.add(1)
answers.add(0)
print(len(answers))
print(" ".join([str(a) for a in sorted(answers)])) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for i in range(t):
n = int(input())
l = [x for x in range(int(n ** (1 / 2)) + 1)] + [
int(n / i) for i in range(1, int(n ** (1 / 2)) + 1)
]
s = set(l)
k = list(s)
k.sort()
m = [str(x) for x in k]
print(len(k))
print(" ".join(m)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | di = {}
for _ in range(int(input())):
n = int(input())
if n in di:
print(di[n][0])
print(di[n][1])
continue
s1 = set()
s1.add(1)
s1.add(n)
s1.add(0)
min = n
i = 2
while i <= min:
next = n // i
min = next
s1.add(next)
if n // next == i:
s1.add(i)
i += 1
s = ""
ans = " ".join(str(k) for k in sorted(list(s1)))
print(len(s1))
print(ans)
di[n] = [len(s1), ans] | ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST FUNC_CALL VAR VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | import sys
try:
sys.stdin = open("input.txt", "r")
sys.stdout = open("output.txt", "w")
except:
pass
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
ans = [0]
div = n
while div >= 1:
val = n // div
if ans[-1] != val:
ans.append(val)
div = n // (val + 1)
print(len(ans))
print(*ans) | IMPORT ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(0, int(input())):
n = int(input())
answers = [0]
i = 1
j = int(n ** (1 / 2))
while i < j:
answers.append(i)
answers.append(n // i)
i += 1
answers.append(j)
if n // j != j:
answers.append(n // j)
answers.sort()
print(len(answers))
print(*answers) | FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | from sys import stdin, stdout
t = int(input())
for _ in range(t):
n = int(input())
a = []
L = [i for i in range(int(n ** (1 / 2) + 1))] + [
int(n / i) for i in range(1, int(n ** (1 / 2) + 1))
]
a = list(map(str, sorted(list(set(L)))))
print(len(a))
print(*a) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
rts = [0]
for i in range(1, int(n**0.5) + 1):
rts.append(n // i)
rts.append(i)
rts = set(rts)
print(len(rts))
print(" ".join([str(x) for x in sorted(rts)])) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
ret = {0}
d = 1
while d * d <= n:
ret.update((n // d, d))
d += 1
print("%d\n%s" % (len(ret), " ".join(map(str, sorted(ret))))) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | import sys
input = sys.stdin.readline
t = int(input())
for testcases in range(t):
n = int(input())
ANS = [n // 1]
for i in range(2, n):
ANS.append(n // i)
if n / (i - 1) - n / i < 1:
break
A = list(range(0, ANS[-1])) + sorted(set(ANS))
print(len(A))
print(*A) | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for t in range(int(input())):
n = int(input())
arr = [0]
div = n
next = 1
while div > 0:
div = n // next
if div != 0:
no = n // div
next = no + 1
arr.append(no)
print(len(arr))
print(*arr) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for query in range(t):
n = int(input())
mylist = [0]
mylist2 = []
counter = 1
total = 1
mystring = ""
while True:
if counter + 1 > int(n / counter + 1):
break
mylist.append(counter)
total = total + 1
if counter == int(n / counter):
break
mylist2.append(int(n / counter))
total = total + 1
counter = counter + 1
print(total)
for num in mylist:
print(num, end=" ")
for num in mylist2[::-1]:
print(num, end=" ") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING WHILE NUMBER IF BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING FOR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR STRING |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for i in range(0, t):
n = int(input())
ln = [0]
oned = False
sqt = n // int(n**0.5)
on = -1
for j in range(1, max(2, int(n**0.5) + 1)):
if n // j != on:
ln.append(n // j)
if n // j == 1:
oned = True
on = n // j
for j in range(len(ln) - 1, 0, -1):
if n // ln[j] == sqt:
continue
ln.append(n // ln[j])
if n // ln[j] == 1:
oned = True
if not oned:
ln.append(1)
print(len(ln))
print(" ".join([str(j) for j in sorted(ln)])) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for _ in range(t):
n = int(input())
set_ = set()
for i in range(1, int(n**0.5) + 10):
set_.add(n // i)
li = sorted(list(set_))
num = li[0]
li2 = [i for i in range(num)]
print(len(li2) + len(li))
print(*(li2 + li)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | T = int(input())
for _ in range(T):
n = int(input())
ans = []
if n == 1:
print(2)
print(0, 1)
continue
elif n == 2:
print(3)
print(0, 1, 2)
continue
elif n == 3:
print(3)
print(0, 1, 3)
continue
k = n // 2
a = 2
l = 1
r = n // 2
ans = [0, 1]
while True:
ans.append(a)
if r == 1:
break
while l <= r:
mid = (l + r) // 2
if n // mid > a:
a1 = n // mid
a2 = mid
l = mid + 1
else:
r = mid - 1
a = a1
r = a2
l = 1
print(len(ans))
print(*ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER WHILE NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
ret = set()
n = int(input())
ret.add(0)
i = 1
while i * i <= n:
tmp = n // i
if n // tmp == i:
ret.add(i)
ret.add(n // i)
i += 1
ans = list(ret)
ans.sort()
print(len(ans))
print(" ".join([str(item) for item in ans])) | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR 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 VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
ans = []
i = 1
while i < n:
if len(ans) != 0:
if ans[-1] == n // i:
break
ans.append(n // i)
i += 1
if len(ans) == 0:
print(2)
print("0 1")
continue
for i in range(ans[-1] - 1, -1, -1):
ans.append(i)
print(len(ans))
print(" ".join(map(str, ans[::-1]))) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER 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 NUMBER |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for t in range(int(input())):
n = int(input())
i = 1
a = set()
while i * i <= n:
a.add(n // i)
i += 1
for j in range(i):
if j not in a:
a.add(j)
a = list(a)
a.sort()
print(len(a))
print(*a) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR 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 |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for i in range(0, t):
n = int(input())
L = [0, 1]
if n == 1:
print(2)
print(*L)
else:
y = int(n**0.5)
L = [i for i in range(y + 1)]
for i in range(y + 1, 0, -1):
x = n // i
if L[-1] < x:
L.append(x)
print(len(L))
print(*L) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
s, l = [0], []
for d in range(1, n // 2 + 2):
if n // d <= s[-1]:
break
l.append(n // d)
if d >= l[-1]:
break
s.append(d)
s += l[::-1]
print(len(s))
print(" ".join(str(i) for i in s)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST NUMBER LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for i in " " * t:
n = int(input())
r = {0, 1, n}
d = 2
while d * d <= n:
r.add(n // d)
r.add(n // (n // d))
d += 1
print(len(r))
print(*sorted(r)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER NUMBER VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for i in range(int(input())):
n = int(input())
l = [0]
l2 = []
x = int(n**0.5)
for i in range(1, x + 1):
l.append(i)
l.append(n // i)
l.sort()
print(len(set(l)))
s1 = set([])
for i in l:
if i not in s1:
l2.append(i)
s1.add(i)
else:
s1.add(i)
print(*l2) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
def solve():
n = int(input())
ans = set()
ans.add(0)
ans.add(1)
ans.add(n)
i = 2
while i * i <= n:
if n / i == n // i:
ans.add(int(i))
ans.add(int(n // i))
else:
ans.add(int(i))
ans.add(n // i)
i += 1
l = sorted(list(ans))
print(len(ans))
print(" ".join(map(str, l)))
T = int(input())
for _ in range(T):
solve() | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR 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 FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for _ in range(t):
n = int(input())
aa = []
ind = 1
while True:
aa.append(n // ind)
if len(aa) >= 2:
if aa[-1] == aa[-2]:
for i in range(aa[-1], -1, -1):
aa.append(i)
break
ind += 1
print(len(set(aa)))
print(*sorted(list(set(aa)))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | from sys import stdin
def input():
return stdin.readline()[:-1]
for _ in range(int(input())):
n = int(input())
output = [n]
while output[-1] != 1:
l, r = 1, n
while l < r:
mid = (l + r) // 2
if n // mid < output[-1]:
r = mid
else:
l = mid + 1
output.append(n // l)
output.append(0)
print(len(output))
print(" ".join(list(map(str, output[::-1])))) | FUNC_DEF RETURN FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR WHILE VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | import sys
input = sys.stdin.buffer.readline
def solution():
n = int(input())
x = int(n**0.5)
l = [0]
i = 1
while i <= x:
a = n // i
l.append(i)
l.append(a)
i += 1
l = list(set(l))
l.sort()
print(len(l))
print(*l)
for _ in range(int(input())):
solution() | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for I in range(t):
n = int(input())
a = set()
for i in range(1, int(n**0.5) + 1):
a.add(i)
a.add(n // i)
a.add(0)
print(len(a))
a = sorted(list(a))
for i in a:
print(i, end=" ")
print() | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
N = int(input())
S = set()
S.add(0)
S.add(N)
for i in range(1, int(N**0.5) + 1):
S.add(i)
S.add(int(N // i))
print(len(S))
L = sorted(S)
for i in L:
print(i, end=" ")
print() | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for i in range(t):
n = int(input())
s = set()
f = []
for j in range(1, int(n**0.5) + 1):
d = n // j
e = n // (n // j)
if d not in s:
s.add(d)
f.append(d)
if e not in s:
s.add(e)
f.append(e)
f.append(0)
f.sort()
print(len(f))
print(*f, sep=" ") | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR STRING |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
for _ in range(t):
n = int(input())
ans = set()
for i in range(1, n + 2):
if n // i not in ans:
ans.add(n // i)
else:
ans = ans.union(set(list(range(0, n // i))))
break
print(len(ans))
print(" ".join(map(str, sorted(ans)))) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP 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 |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | t = int(input())
while t:
t -= 1
n = int(input())
ans = []
i = 0
while i * i <= n:
ans.append(i)
if i:
ans.append(n // i)
i += 1
ans = list(set(ans))
ans.sort()
print(len(ans))
print(*ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | for _ in range(int(input())):
n = int(input())
a = set()
i = 1
while i * i <= n:
a.add(n // i)
a.add(i)
i += 1
a.add(n)
a.add(0)
a = list(a)
a.sort()
print(len(a))
print(*a) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
On the well-known testing system MathForces, a draw of $n$ rating units is arranged. The rating will be distributed according to the following algorithm: if $k$ participants take part in this event, then the $n$ rating is evenly distributed between them and rounded to the nearest lower integer, At the end of the drawing, an unused rating may remain — it is not given to any of the participants.
For example, if $n = 5$ and $k = 3$, then each participant will recieve an $1$ rating unit, and also $2$ rating units will remain unused. If $n = 5$, and $k = 6$, then none of the participants will increase their rating.
Vasya participates in this rating draw but does not have information on the total number of participants in this event. Therefore, he wants to know what different values of the rating increment are possible to get as a result of this draw and asks you for help.
For example, if $n=5$, then the answer is equal to the sequence $0, 1, 2, 5$. Each of the sequence values (and only them) can be obtained as $\lfloor n/k \rfloor$ for some positive integer $k$ (where $\lfloor x \rfloor$ is the value of $x$ rounded down): $0 = \lfloor 5/7 \rfloor$, $1 = \lfloor 5/5 \rfloor$, $2 = \lfloor 5/2 \rfloor$, $5 = \lfloor 5/1 \rfloor$.
Write a program that, for a given $n$, finds a sequence of all possible rating increments.
-----Input-----
The first line contains integer number $t$ ($1 \le t \le 10$) — the number of test cases in the input. Then $t$ test cases follow.
Each line contains an integer $n$ ($1 \le n \le 10^9$) — the total number of the rating units being drawn.
-----Output-----
Output the answers for each of $t$ test cases. Each answer should be contained in two lines.
In the first line print a single integer $m$ — the number of different rating increment values that Vasya can get.
In the following line print $m$ integers in ascending order — the values of possible rating increments.
-----Example-----
Input
4
5
11
1
3
Output
4
0 1 2 5
6
0 1 2 3 5 11
2
0 1
3
0 1 3 | def main():
n = int(input())
num = n // 2
ans = [0, 1]
prev = 1
l = 2
while num > 0:
temp = n // num
if temp != prev:
l += 1
prev = temp
ans.append(temp)
num = n // (temp + 1)
else:
num -= 1
print(l)
print(*ans)
t = int(input())
for _ in range(t):
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.