結果
問題 | No.757 チャンパーノウン定数 (2) |
ユーザー | mkawa2 |
提出日時 | 2022-02-02 11:38:05 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,509 bytes |
コンパイル時間 | 946 ms |
コンパイル使用メモリ | 87,328 KB |
実行使用メモリ | 84,360 KB |
最終ジャッジ日時 | 2023-09-02 02:42:17 |
合計ジャッジ時間 | 11,666 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 67 ms
75,848 KB |
testcase_01 | AC | 66 ms
71,640 KB |
testcase_02 | AC | 65 ms
71,564 KB |
testcase_03 | AC | 63 ms
71,636 KB |
testcase_04 | AC | 65 ms
71,300 KB |
testcase_05 | AC | 63 ms
71,308 KB |
testcase_06 | AC | 64 ms
71,496 KB |
testcase_07 | AC | 67 ms
71,220 KB |
testcase_08 | AC | 68 ms
71,408 KB |
testcase_09 | AC | 64 ms
71,324 KB |
testcase_10 | AC | 68 ms
71,400 KB |
testcase_11 | AC | 67 ms
71,620 KB |
testcase_12 | AC | 66 ms
71,424 KB |
testcase_13 | AC | 67 ms
71,400 KB |
testcase_14 | AC | 68 ms
71,612 KB |
testcase_15 | AC | 65 ms
71,412 KB |
testcase_16 | AC | 66 ms
71,564 KB |
testcase_17 | AC | 65 ms
71,316 KB |
testcase_18 | AC | 66 ms
71,408 KB |
testcase_19 | AC | 68 ms
71,620 KB |
testcase_20 | AC | 69 ms
71,304 KB |
testcase_21 | AC | 65 ms
71,356 KB |
testcase_22 | AC | 69 ms
71,632 KB |
testcase_23 | AC | 70 ms
71,468 KB |
testcase_24 | AC | 69 ms
71,608 KB |
testcase_25 | AC | 67 ms
71,260 KB |
testcase_26 | AC | 67 ms
71,516 KB |
testcase_27 | AC | 65 ms
71,604 KB |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | AC | 83 ms
75,636 KB |
testcase_31 | AC | 108 ms
76,136 KB |
testcase_32 | AC | 66 ms
71,304 KB |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | AC | 121 ms
76,244 KB |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | RE | - |
testcase_41 | RE | - |
testcase_42 | AC | 1,307 ms
84,360 KB |
testcase_43 | TLE | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
testcase_52 | -- | - |
testcase_53 | -- | - |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 18446744073709551615 # inf = 4294967295 # md = 10**9+7 md = 998244353 # aけたまでの整数を並べたときの長さ def length(a): res = b**a*a-(b**a-1)//(b-1) return res def binary_search(l, r, ok, minimize): if minimize: l -= 1 else: r += 1 while l+1 < r: m = (l+r)//2 if ok(m) ^ minimize: l = m else: r = m if minimize: return r return l def base_b(a, b): res = [] while a: a, r = divmod(a, b) res.append(r) return res[::-1] def ok(a): return length(a) >= d b = II() s = SI() d = int(s, b) n = len(s) # 最後の整数の桁数 a = binary_search(1, n, ok, True) # print(a) # leading0を付けたときの長さ za = d+(b**a-1)//(b-1)-1 # za = d+length(a-1)+1 # 最後の整数 r = za//a # print(base_b(r, b)) ans = base_b(r, b)[za%a] print(ans)