QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#390804 | #4770. Binomial coefficients | I_Love_Sonechka# | RE | 0ms | 0kb | Python3 | 885b | 2024-04-15 22:12:57 | 2024-04-15 22:12:58 |
answer
def solve():
inf = 1e18
def cnk(n, k):
if(k >= n):
return 0
res = 1
for i in range(n-k+1, n+1):
res *= i;
for i in range(1, k+1):
res //= i;
return min(res, inf);
def mx(k):
l = 0
r = int(1e15)
while r - l > 1:
med = (l+r) // 2
if(cnk(med, k) <= m):
l = med
else:
r = med
return l
m = int(input())
st = []
for k in range(0, min(m+1, 1000)):
n = mx(k)
if cnk(n, k) == m and k <= n -k:
if k != n-k:
st.append(f"({n},{n-k})")
st.append(f"({n},{k})")
st.reverse()
print(st.size())
for x in st:
print(x, end = " ")
print()
tt = int(input())
for i in range(tt):
solve()
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
2 2 15