QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#390804#4770. Binomial coefficientsI_Love_Sonechka#RE 0ms0kbPython3885b2024-04-15 22:12:572024-04-15 22:12:58

Judging History

你现在查看的是最新测评结果

  • [2024-04-15 22:12:58]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-04-15 22:12:57]
  • 提交

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

output:


result: