結果

問題 No.1651 Removing Cards
ユーザー H3PO4H3PO4
提出日時 2024-04-18 19:54:17
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 938 ms / 2,000 ms
コード長 355 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 25,216 KB
最終ジャッジ日時 2024-04-18 19:54:43
合計ジャッジ時間 24,527 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,752 KB
testcase_01 AC 25 ms
10,752 KB
testcase_02 AC 85 ms
15,360 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 25 ms
10,880 KB
testcase_06 AC 28 ms
10,880 KB
testcase_07 AC 26 ms
10,752 KB
testcase_08 AC 36 ms
10,752 KB
testcase_09 AC 536 ms
10,880 KB
testcase_10 AC 570 ms
10,752 KB
testcase_11 AC 560 ms
10,880 KB
testcase_12 AC 605 ms
10,752 KB
testcase_13 AC 559 ms
10,880 KB
testcase_14 AC 547 ms
10,752 KB
testcase_15 AC 871 ms
24,960 KB
testcase_16 AC 854 ms
24,576 KB
testcase_17 AC 911 ms
24,960 KB
testcase_18 AC 886 ms
24,192 KB
testcase_19 AC 904 ms
24,448 KB
testcase_20 AC 932 ms
23,936 KB
testcase_21 AC 903 ms
24,320 KB
testcase_22 AC 869 ms
25,088 KB
testcase_23 AC 652 ms
10,752 KB
testcase_24 AC 613 ms
10,880 KB
testcase_25 AC 819 ms
25,088 KB
testcase_26 AC 857 ms
24,320 KB
testcase_27 AC 900 ms
25,088 KB
testcase_28 AC 926 ms
25,088 KB
testcase_29 AC 938 ms
25,216 KB
testcase_30 AC 920 ms
25,088 KB
testcase_31 AC 932 ms
25,216 KB
testcase_32 AC 640 ms
10,880 KB
testcase_33 AC 554 ms
10,880 KB
testcase_34 AC 584 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_right

K, Q = map(int, input().split())


def ceildiv(x, y):
    return (x + y - 1) // y


lst = [1]
MAX = 10**18
while lst[-1] <= MAX:
    # y = x - (x + K - 1) // K
    # x = y * K / (K - 1)
    x = ceildiv(lst[-1] * K, K - 1)
    lst.append(x)

for _ in range(Q):
    n = int(input())
    print(lst[bisect_right(lst, n) - 1])
0