結果

問題 No.1651 Removing Cards
ユーザー shotoyooshotoyoo
提出日時 2021-08-20 23:49:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,406 ms / 2,000 ms
コード長 837 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 96,640 KB
最終ジャッジ日時 2024-04-22 08:49:41
合計ジャッジ時間 25,360 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
57,728 KB
testcase_01 AC 42 ms
58,240 KB
testcase_02 AC 379 ms
79,356 KB
testcase_03 AC 42 ms
57,984 KB
testcase_04 AC 42 ms
58,880 KB
testcase_05 AC 43 ms
58,516 KB
testcase_06 AC 43 ms
58,240 KB
testcase_07 AC 45 ms
58,624 KB
testcase_08 AC 44 ms
59,264 KB
testcase_09 AC 113 ms
75,904 KB
testcase_10 AC 118 ms
76,672 KB
testcase_11 AC 118 ms
76,468 KB
testcase_12 AC 117 ms
76,032 KB
testcase_13 AC 120 ms
76,544 KB
testcase_14 AC 121 ms
75,988 KB
testcase_15 AC 1,363 ms
96,312 KB
testcase_16 AC 1,291 ms
94,208 KB
testcase_17 AC 1,342 ms
95,092 KB
testcase_18 AC 1,293 ms
94,720 KB
testcase_19 AC 1,297 ms
95,360 KB
testcase_20 AC 1,287 ms
93,648 KB
testcase_21 AC 1,270 ms
94,900 KB
testcase_22 AC 1,335 ms
96,640 KB
testcase_23 AC 109 ms
76,032 KB
testcase_24 AC 100 ms
75,776 KB
testcase_25 AC 1,405 ms
96,532 KB
testcase_26 AC 1,319 ms
94,976 KB
testcase_27 AC 1,359 ms
96,384 KB
testcase_28 AC 1,347 ms
95,980 KB
testcase_29 AC 1,406 ms
96,256 KB
testcase_30 AC 1,404 ms
96,512 KB
testcase_31 AC 1,367 ms
95,216 KB
testcase_32 AC 128 ms
76,160 KB
testcase_33 AC 131 ms
76,288 KB
testcase_34 AC 131 ms
76,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))

def nx(v):
    l = 0
    r = k*v
    while abs(l-r)>1:
        m = (l+r)//2
        if (m) - (m+k-1)//k >= v:
            r = m
        else:
            l = m
#     if (r-1)%k==0:
#         r += 1
    return r
def sub0(n,k):
    l = list(range(1,k+1))
    v = nx(k)
    while v<=n:
        l.append(v)
        v = nx(v)
    l.append(v)
    return l
k,q = list(map(int, input().split()))
l = sub0(10**18+10,k)
from bisect import bisect_left as bl
for i in range(q):
    n = int(input())
    if n==1:
        write("1")
        continue
    ind = bl(l, n)
    if l[ind]>n:
        ind -= 1
    write(str(l[ind]))
0