結果
問題 |
No.2589 Prepare Integers
|
ユーザー |
|
提出日時 | 2023-12-12 13:08:54 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 683 bytes |
コンパイル時間 | 272 ms |
コンパイル使用メモリ | 82,464 KB |
実行使用メモリ | 386,600 KB |
最終ジャッジ日時 | 2024-09-27 07:50:45 |
合計ジャッジ時間 | 4,170 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 TLE * 1 |
other | -- * 24 |
ソースコード
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))