結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー mkawa2mkawa2
提出日時 2022-02-02 11:47:15
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,393 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 87,232 KB
実行使用メモリ 79,428 KB
最終ジャッジ日時 2023-09-02 02:42:28
合計ジャッジ時間 7,138 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,428 KB
testcase_01 AC 70 ms
71,484 KB
testcase_02 AC 72 ms
71,612 KB
testcase_03 AC 69 ms
71,536 KB
testcase_04 AC 66 ms
71,168 KB
testcase_05 AC 65 ms
71,420 KB
testcase_06 AC 66 ms
71,460 KB
testcase_07 AC 67 ms
71,316 KB
testcase_08 AC 66 ms
71,328 KB
testcase_09 AC 66 ms
71,576 KB
testcase_10 AC 67 ms
71,496 KB
testcase_11 AC 68 ms
71,500 KB
testcase_12 AC 68 ms
71,500 KB
testcase_13 AC 68 ms
71,444 KB
testcase_14 AC 67 ms
71,448 KB
testcase_15 AC 67 ms
71,480 KB
testcase_16 AC 66 ms
71,580 KB
testcase_17 AC 67 ms
71,160 KB
testcase_18 AC 66 ms
71,164 KB
testcase_19 AC 68 ms
71,652 KB
testcase_20 AC 68 ms
71,324 KB
testcase_21 AC 67 ms
71,436 KB
testcase_22 AC 68 ms
71,428 KB
testcase_23 AC 69 ms
71,196 KB
testcase_24 AC 69 ms
71,412 KB
testcase_25 AC 69 ms
71,456 KB
testcase_26 AC 68 ms
71,160 KB
testcase_27 AC 68 ms
71,436 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 69 ms
71,528 KB
testcase_31 AC 70 ms
71,356 KB
testcase_32 AC 68 ms
71,316 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 AC 69 ms
71,488 KB
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 70 ms
71,188 KB
testcase_43 AC 86 ms
71,440 KB
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 78 ms
71,432 KB
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 AC 67 ms
71,164 KB
testcase_51 AC 70 ms
71,564 KB
testcase_52 AC 68 ms
71,428 KB
testcase_53 AC 67 ms
71,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 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