結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー omochanalomochanal
提出日時 2018-12-19 18:13:06
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 679 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 81,860 KB
実行使用メモリ 92,940 KB
最終ジャッジ日時 2023-10-26 00:02:36
合計ジャッジ時間 18,320 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,600 KB
testcase_01 AC 37 ms
53,600 KB
testcase_02 AC 38 ms
53,600 KB
testcase_03 AC 38 ms
53,600 KB
testcase_04 AC 37 ms
53,600 KB
testcase_05 AC 37 ms
53,600 KB
testcase_06 AC 38 ms
53,600 KB
testcase_07 AC 36 ms
53,600 KB
testcase_08 AC 37 ms
55,648 KB
testcase_09 AC 38 ms
55,648 KB
testcase_10 AC 36 ms
53,600 KB
testcase_11 AC 36 ms
53,600 KB
testcase_12 AC 35 ms
53,600 KB
testcase_13 AC 37 ms
53,600 KB
testcase_14 AC 36 ms
53,600 KB
testcase_15 AC 37 ms
53,600 KB
testcase_16 AC 35 ms
53,600 KB
testcase_17 AC 37 ms
55,648 KB
testcase_18 AC 40 ms
55,648 KB
testcase_19 AC 36 ms
53,600 KB
testcase_20 AC 37 ms
53,600 KB
testcase_21 AC 37 ms
53,600 KB
testcase_22 AC 37 ms
53,600 KB
testcase_23 AC 38 ms
53,600 KB
testcase_24 AC 38 ms
53,600 KB
testcase_25 AC 37 ms
53,600 KB
testcase_26 AC 38 ms
55,648 KB
testcase_27 AC 38 ms
55,648 KB
testcase_28 AC 1,373 ms
82,932 KB
testcase_29 AC 1,061 ms
80,580 KB
testcase_30 AC 48 ms
72,140 KB
testcase_31 AC 69 ms
75,132 KB
testcase_32 AC 39 ms
55,648 KB
testcase_33 AC 72 ms
75,136 KB
testcase_34 AC 361 ms
76,072 KB
testcase_35 AC 60 ms
75,124 KB
testcase_36 AC 52 ms
75,124 KB
testcase_37 AC 817 ms
78,784 KB
testcase_38 AC 1,188 ms
81,532 KB
testcase_39 AC 1,549 ms
84,724 KB
testcase_40 TLE -
testcase_41 AC 933 ms
78,252 KB
testcase_42 AC 352 ms
75,396 KB
testcase_43 AC 905 ms
77,212 KB
testcase_44 AC 900 ms
78,248 KB
testcase_45 AC 639 ms
76,572 KB
testcase_46 AC 637 ms
76,072 KB
testcase_47 AC 776 ms
77,172 KB
testcase_48 AC 470 ms
75,824 KB
testcase_49 AC 724 ms
77,060 KB
testcase_50 AC 39 ms
55,648 KB
testcase_51 AC 38 ms
53,600 KB
testcase_52 AC 36 ms
53,600 KB
testcase_53 AC 36 ms
53,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Base_10_to_n(X, n, R):
    if X == n ** (R + 1):
        return 1
    X = X // (n ** R)
    return X % n

def Base_n_to_10(X,n):
    out = 0
    tmp = 1
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*tmp
        tmp *= n
    return out#int out

def f(l, B):
    return ((l * B - l - 1) * B ** l + 1) // (B - 1)

B = input()
N = input()
B = int(B)

N = Base_n_to_10(N, B) - 1

l = 0
lv = 0
rv = 100000

while rv - lv > 1:
    m = (lv + rv) // 2
    if f(m, B) < N:
        lv = m
    else:
        rv = m

l = lv
bound = f(l, B)

N -= bound
Q = N // (l + 1) + B ** l
R = N % (l + 1)

# print(N, Q, R, l, bound)
print(Base_10_to_n(Q, B, l - R))

# print(Q, R)

0