結果

問題 No.2589 Prepare Integers
ユーザー hirayuu_ychirayuu_yc
提出日時 2023-12-12 13:08:54
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 683 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 501,912 KB
最終ジャッジ日時 2023-12-16 23:30:18
合計ジャッジ時間 4,079 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
66,388 KB
testcase_01 AC 44 ms
59,584 KB
testcase_02 AC 203 ms
88,296 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect
def f(x,y):
    ret=0
    for i in range(L):
        ret+=pow(K,i)*((x%K+y%K)%K)
        x//=K
        y//=K
    return ret

K,Q=map(int,input().split())
L=1
lg=1
while lg<10**10:
    lg*=K
    L+=1
used={0}
ap=[0]
for i in range(Q):
    t,x=map(int,input().split())
    if t==1:
        if x in used:
            continue
        aft=set()
        for i in used:
            now=i
            for j in range(K):
                aft.add(now)
                now=f(now,x)
        used=aft
        ap=sorted(list(used))
    elif t==2:
        if len(used)<x:
            print(-1)
        else:
            print(ap[x-1])
    else:
        print(bisect(ap,x))
0