QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#635534#9456. Numbersucup-team296#AC ✓36ms10656kbPython3356b2024-10-12 20:05:212024-10-14 17:30:39

Judging History

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

  • [2024-10-14 17:30:39]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:36ms
  • 内存:10656kb
  • [2024-10-14 17:30:02]
  • hack成功,自动添加数据
  • (/hack/994)
  • [2024-10-14 17:05:10]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:35ms
  • 内存:10652kb
  • [2024-10-14 17:04:20]
  • hack成功,自动添加数据
  • (/hack/992)
  • [2024-10-12 20:05:21]
  • 评测
  • 测评结果:100
  • 用时:32ms
  • 内存:10744kb
  • [2024-10-12 20:05:21]
  • 提交

answer

def solve():
    n, m = map(int, input().split())
    p = 0
    while (1 << p) * m <= n:
        p += 1
    res = 0
    for k in range(p, -1, -1):
        if ((1 << k) - 1) * m >= n:
            continue
        res += (1 << k)
        c = min(m, n >> k)
        n -= c << k
    print(res)

t = int(input())
for i in range(t):
    solve()

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 16ms
memory: 10656kb

input:

5
3 1
3 2
3 3
10000 5
1244 10

output:

3
3
1
2000
125

result:

ok 5 tokens

Test #2:

score: 0
Accepted
time: 36ms
memory: 10648kb

input:

760
3 1
3 2
3 3
10000 5
1234 10
12345678910 34
124243243453446456 111323444
124234235325435436454645 242342343
232243434 23223
237234873238642783459236523976 10
0 1
0 12
1 3
10 4
9 5
3 2
4 5
7 3
6 2
5 3
7 3
7 2
9685295 190
5556910 213
7111987 191
7215414 122
5850275 271
4249528 191
3215769 167
26903...

output:

3
3
1
2000
125
363108205
1116056412
512639408316011
10001
23723487323864278345923652398
0
0
1
3
3
3
1
3
3
3
3
7
50977
26089
37237
59143
21589
22249
19257
12514
4955
69867
34099
67319
14241
26433
29343
26521
44241
19009
61709
10829
11557
39115
70165
26403
5215
28595
47438
15065
31705
27509
18483
7105...

result:

ok 760 tokens

Extra Test:

score: 0
Extra Test Passed