結果

問題 No.1651 Removing Cards
ユーザー KudeKude
提出日時 2021-08-20 22:57:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 460 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 874 ms
コンパイル使用メモリ 82,452 KB
実行使用メモリ 102,092 KB
最終ジャッジ日時 2024-04-22 06:38:40
合計ジャッジ時間 14,071 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,968 KB
testcase_01 AC 40 ms
51,584 KB
testcase_02 AC 64 ms
79,744 KB
testcase_03 AC 41 ms
52,096 KB
testcase_04 AC 41 ms
52,896 KB
testcase_05 AC 41 ms
52,736 KB
testcase_06 AC 42 ms
52,352 KB
testcase_07 AC 41 ms
52,096 KB
testcase_08 AC 41 ms
52,096 KB
testcase_09 AC 298 ms
76,336 KB
testcase_10 AC 304 ms
76,244 KB
testcase_11 AC 304 ms
76,288 KB
testcase_12 AC 310 ms
76,268 KB
testcase_13 AC 306 ms
75,904 KB
testcase_14 AC 308 ms
76,160 KB
testcase_15 AC 437 ms
101,760 KB
testcase_16 AC 459 ms
99,200 KB
testcase_17 AC 438 ms
99,712 KB
testcase_18 AC 433 ms
99,456 KB
testcase_19 AC 430 ms
99,200 KB
testcase_20 AC 429 ms
99,200 KB
testcase_21 AC 433 ms
99,200 KB
testcase_22 AC 360 ms
102,092 KB
testcase_23 AC 287 ms
76,544 KB
testcase_24 AC 275 ms
76,032 KB
testcase_25 AC 361 ms
101,888 KB
testcase_26 AC 368 ms
99,456 KB
testcase_27 AC 426 ms
102,016 KB
testcase_28 AC 447 ms
101,632 KB
testcase_29 AC 460 ms
102,060 KB
testcase_30 AC 436 ms
102,016 KB
testcase_31 AC 448 ms
102,016 KB
testcase_32 AC 292 ms
75,904 KB
testcase_33 AC 303 ms
75,904 KB
testcase_34 AC 292 ms
76,544 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