結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー mkawa2mkawa2
提出日時 2023-06-12 23:16:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 250 ms / 2,000 ms
コード長 1,429 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 72,496 KB
最終ジャッジ日時 2023-09-02 16:21:02
合計ジャッジ時間 10,113 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,056 KB
testcase_01 AC 74 ms
70,912 KB
testcase_02 AC 73 ms
71,316 KB
testcase_03 AC 74 ms
71,020 KB
testcase_04 AC 73 ms
71,396 KB
testcase_05 AC 74 ms
70,908 KB
testcase_06 AC 72 ms
71,384 KB
testcase_07 AC 73 ms
71,344 KB
testcase_08 AC 73 ms
71,208 KB
testcase_09 AC 80 ms
71,328 KB
testcase_10 AC 73 ms
71,164 KB
testcase_11 AC 72 ms
71,380 KB
testcase_12 AC 72 ms
71,164 KB
testcase_13 AC 73 ms
71,396 KB
testcase_14 AC 74 ms
71,352 KB
testcase_15 AC 73 ms
70,916 KB
testcase_16 AC 73 ms
71,424 KB
testcase_17 AC 73 ms
71,060 KB
testcase_18 AC 72 ms
71,348 KB
testcase_19 AC 73 ms
71,200 KB
testcase_20 AC 73 ms
71,028 KB
testcase_21 AC 73 ms
71,268 KB
testcase_22 AC 73 ms
71,244 KB
testcase_23 AC 72 ms
71,244 KB
testcase_24 AC 72 ms
71,056 KB
testcase_25 AC 73 ms
71,268 KB
testcase_26 AC 73 ms
71,324 KB
testcase_27 AC 72 ms
71,128 KB
testcase_28 AC 168 ms
72,112 KB
testcase_29 AC 163 ms
72,048 KB
testcase_30 AC 73 ms
70,908 KB
testcase_31 AC 74 ms
71,172 KB
testcase_32 AC 74 ms
71,124 KB
testcase_33 AC 75 ms
70,908 KB
testcase_34 AC 104 ms
71,472 KB
testcase_35 AC 74 ms
71,388 KB
testcase_36 AC 74 ms
71,256 KB
testcase_37 AC 138 ms
71,572 KB
testcase_38 AC 158 ms
72,120 KB
testcase_39 AC 175 ms
71,920 KB
testcase_40 AC 250 ms
72,496 KB
testcase_41 AC 244 ms
72,396 KB
testcase_42 AC 83 ms
71,424 KB
testcase_43 AC 93 ms
71,248 KB
testcase_44 AC 235 ms
72,376 KB
testcase_45 AC 171 ms
72,252 KB
testcase_46 AC 75 ms
71,416 KB
testcase_47 AC 196 ms
72,240 KB
testcase_48 AC 125 ms
71,796 KB
testcase_49 AC 173 ms
72,092 KB
testcase_50 AC 73 ms
71,268 KB
testcase_51 AC 71 ms
71,344 KB
testcase_52 AC 71 ms
70,904 KB
testcase_53 AC 72 ms
71,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.set_int_max_str_digits(1000005)
# 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 digit(a, i, b):
    a //= b**i
    return a%b

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)

# leading0を付けたときの長さ
zd = d+(b**a-1)//(b-1)-1

# 最後の整数
r = zd//a

ans = digit(r, a-1-zd%a, b)

print(ans)
0