結果

問題 No.1651 Removing Cards
ユーザー shotoyooshotoyoo
提出日時 2021-08-20 23:45:33
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 821 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 97,128 KB
最終ジャッジ日時 2024-04-22 08:44:22
合計ジャッジ時間 24,408 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
58,784 KB
testcase_01 AC 42 ms
59,024 KB
testcase_02 AC 381 ms
79,472 KB
testcase_03 AC 41 ms
57,996 KB
testcase_04 AC 43 ms
58,640 KB
testcase_05 AC 43 ms
59,524 KB
testcase_06 AC 43 ms
58,388 KB
testcase_07 AC 44 ms
59,624 KB
testcase_08 AC 44 ms
59,284 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 1,379 ms
96,432 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 1,301 ms
95,396 KB
testcase_19 AC 1,299 ms
95,188 KB
testcase_20 AC 1,287 ms
93,808 KB
testcase_21 AC 1,279 ms
94,896 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 100 ms
76,200 KB
testcase_25 AC 1,347 ms
96,416 KB
testcase_26 AC 1,285 ms
95,592 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 1,411 ms
96,468 KB
testcase_30 AC 1,413 ms
96,652 KB
testcase_31 AC 1,381 ms
95,280 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

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)
    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