結果

問題 No.1651 Removing Cards
ユーザー KudeKude
提出日時 2021-08-20 22:57:32
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 473 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 1,518 ms
コンパイル使用メモリ 86,684 KB
実行使用メモリ 100,640 KB
最終ジャッジ日時 2023-08-04 08:51:04
合計ジャッジ時間 14,940 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,480 KB
testcase_01 AC 71 ms
71,220 KB
testcase_02 AC 102 ms
84,768 KB
testcase_03 AC 74 ms
71,172 KB
testcase_04 AC 75 ms
71,156 KB
testcase_05 AC 74 ms
71,156 KB
testcase_06 AC 75 ms
71,140 KB
testcase_07 AC 74 ms
70,984 KB
testcase_08 AC 74 ms
71,076 KB
testcase_09 AC 315 ms
78,176 KB
testcase_10 AC 319 ms
77,448 KB
testcase_11 AC 320 ms
78,004 KB
testcase_12 AC 324 ms
77,160 KB
testcase_13 AC 315 ms
77,536 KB
testcase_14 AC 318 ms
77,416 KB
testcase_15 AC 441 ms
100,464 KB
testcase_16 AC 473 ms
100,356 KB
testcase_17 AC 442 ms
100,544 KB
testcase_18 AC 447 ms
100,032 KB
testcase_19 AC 440 ms
100,416 KB
testcase_20 AC 447 ms
100,032 KB
testcase_21 AC 450 ms
100,036 KB
testcase_22 AC 370 ms
100,496 KB
testcase_23 AC 307 ms
77,588 KB
testcase_24 AC 299 ms
77,236 KB
testcase_25 AC 380 ms
100,552 KB
testcase_26 AC 374 ms
100,344 KB
testcase_27 AC 430 ms
100,340 KB
testcase_28 AC 456 ms
100,640 KB
testcase_29 AC 449 ms
100,272 KB
testcase_30 AC 458 ms
100,612 KB
testcase_31 AC 457 ms
100,488 KB
testcase_32 AC 314 ms
78,060 KB
testcase_33 AC 312 ms
77,688 KB
testcase_34 AC 315 ms
77,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

k, q = map(int, input().split())
d = [(1, 2)]
RMX = 10 ** 18
while d[-1][1] <= RMX:
    l, r = d[-1]
    nl = (k * l - 1) // (k - 1) + 1
    nr = (k * r - 1) // (k - 1) + 1
    if r != nl:
        print(k, l, r, nl, nr)
    assert(r == nl)
    d.append((nl, nr))
for _ in range(q):
    n = int(input())
    l = 0
    r = len(d)
    while True:
        c = (l + r) // 2
        lc, rc = d[c]
        if lc <= n < rc:
            print(lc)
            break
        if n < lc:
            r = c
        else:
            l = c + 1
0