結果

問題 No.1651 Removing Cards
ユーザー tassei903tassei903
提出日時 2021-08-20 22:45:42
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 992 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,648 KB
実行使用メモリ 98,136 KB
最終ジャッジ日時 2024-04-22 05:41:08
合計ジャッジ時間 7,278 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,136 KB
testcase_01 AC 43 ms
54,356 KB
testcase_02 AC 60 ms
76,524 KB
testcase_03 AC 40 ms
53,092 KB
testcase_04 AC 40 ms
53,424 KB
testcase_05 AC 42 ms
53,700 KB
testcase_06 AC 41 ms
52,744 KB
testcase_07 AC 41 ms
52,996 KB
testcase_08 AC 41 ms
53,628 KB
testcase_09 AC 124 ms
76,188 KB
testcase_10 AC 124 ms
76,436 KB
testcase_11 AC 127 ms
76,196 KB
testcase_12 AC 131 ms
76,420 KB
testcase_13 AC 128 ms
76,496 KB
testcase_14 AC 127 ms
76,152 KB
testcase_15 AC 193 ms
95,540 KB
testcase_16 AC 190 ms
95,388 KB
testcase_17 AC 190 ms
95,492 KB
testcase_18 AC 196 ms
95,452 KB
testcase_19 AC 192 ms
95,196 KB
testcase_20 AC 188 ms
95,236 KB
testcase_21 AC 195 ms
95,200 KB
testcase_22 AC 157 ms
97,836 KB
testcase_23 AC 119 ms
76,592 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 185 ms
97,612 KB
testcase_28 AC 184 ms
97,844 KB
testcase_29 AC 205 ms
97,884 KB
testcase_30 AC 203 ms
97,892 KB
testcase_31 AC 207 ms
98,080 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes")
no = lambda :print("no");No = lambda :print("No")
inf = 10**16
#######################################################################
k, q = na()

from bisect import *
bl = bisect_left
br = bisect_right


def f(n):
    r = 0
    while True:
        #print(n)
        if n%k==0:
            break
        n = n-(n+k-1)//k
        r+=1
    return r

def g(n):
    r = []
    while n>0:
        r.append(str(n%k))
        n//=k
    return "".join(r[::-1])

def solve(n):
    return 1-ans[bl(ans, -n)]
"""i = 0
j = 1
ans = []
m = -1
N = 10**3
while i<N:
    z = f(i)
    if m<z:
        m = z
        ans.append(i)
    i+=1
"""
dp = [1]
while dp[-1]<=10**18:
    dp.append((dp[-1]*k+k-1)//(k-1))
        
ans = [-i for i in dp][::-1]

for i in range(q):
    n = ni()-1
    print(solve(n))
0