QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#390803#4770. Binomial coefficientsI_Love_Sonechka#WA 6ms9956kbPython3863b2024-04-15 22:12:032024-04-15 22:12:03

Judging History

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

  • [2024-04-15 22:12:03]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:9956kb
  • [2024-04-15 22:12:03]
  • 提交

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()
    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
Wrong Answer
time: 6ms
memory: 9956kb

input:

2
2
15

output:

(2,1) 
(6,2) (6,4) (15,1) (15,14) 

result:

wrong answer 1st lines differ - expected: '1', found: '(2,1) '