結果

問題 No.1651 Removing Cards
ユーザー ayaoniayaoni
提出日時 2021-08-20 22:29:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 1,115 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 98,048 KB
最終ジャッジ日時 2024-04-22 05:15:01
合計ジャッジ時間 6,926 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,840 KB
testcase_01 AC 38 ms
52,096 KB
testcase_02 AC 55 ms
73,344 KB
testcase_03 AC 38 ms
52,352 KB
testcase_04 AC 39 ms
52,352 KB
testcase_05 AC 39 ms
52,480 KB
testcase_06 AC 38 ms
52,480 KB
testcase_07 AC 38 ms
52,096 KB
testcase_08 AC 42 ms
52,992 KB
testcase_09 AC 93 ms
75,904 KB
testcase_10 AC 94 ms
75,904 KB
testcase_11 AC 96 ms
76,276 KB
testcase_12 AC 96 ms
75,904 KB
testcase_13 AC 99 ms
75,904 KB
testcase_14 AC 97 ms
76,032 KB
testcase_15 AC 154 ms
95,744 KB
testcase_16 AC 158 ms
95,232 KB
testcase_17 AC 159 ms
95,360 KB
testcase_18 AC 158 ms
95,104 KB
testcase_19 AC 171 ms
95,360 KB
testcase_20 AC 170 ms
95,488 KB
testcase_21 AC 154 ms
95,360 KB
testcase_22 AC 131 ms
97,792 KB
testcase_23 AC 95 ms
76,288 KB
testcase_24 AC 84 ms
76,288 KB
testcase_25 AC 135 ms
98,048 KB
testcase_26 AC 131 ms
95,196 KB
testcase_27 AC 155 ms
97,664 KB
testcase_28 AC 157 ms
97,792 KB
testcase_29 AC 160 ms
97,672 KB
testcase_30 AC 160 ms
97,672 KB
testcase_31 AC 159 ms
97,536 KB
testcase_32 AC 91 ms
76,204 KB
testcase_33 AC 94 ms
75,776 KB
testcase_34 AC 93 ms
76,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


K,Q = MI()

X = [1]
while True:
    x = X[-1]
    new_x = (x*K+K-2)//(K-1)
    X.append(new_x)
    if new_x > 10**18:
        break
len_X = len(X)

for _ in range(Q):
    N = I()
    ok = 0
    ng = len_X
    while ok+1 < ng:
        mid = (ok+ng)//2
        if X[mid] <= N:
            ok = mid
        else:
            ng = mid
    ans = X[ok]
    print(ans)

'''
K = 4
for i in range(2,1001):
    X = [j for j in range(1,i+1)]
    while True:
        len_X = len(X)
        new_X = []
        for j in range(len_X):
            if j % K != 0:
                new_X.append(X[j])
        X = new_X
        if len(X) == 1:
            break
    print(X[0],i)
'''
0