QOJ.ac

QOJ

ID提交记录ID题目HackerOwner结果提交时间测评时间
#994#634409#9456. Numbershos_lyricucup-team4967Success!2024-10-14 17:29:532024-10-14 17:29:53

詳細信息

Extra Test:

Time Limit Exceeded

input:

20000
0 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
1 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
2 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999...

output:

0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
...

result:


ID题目提交者结果用时内存语言文件大小提交时间测评时间
#634409#9456. Numbersucup-team4967#TL 811ms10620kbPython3299b2024-10-12 17:15:402024-10-14 17:30:26

answer

t = int(input())

for i in range(t):
    n, m = list(map(int, input().split()))
    ans = 0
    pp = 1 << 3500
    for k in range(3500, -1, -1):
        if (pp - 1) * m < n:
            ans += pp
            cnt = min(m, n // pp)
            n -= cnt * pp
        pp >>= 1
    print(ans)