結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー omochanalomochanal
提出日時 2018-12-19 18:10:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 683 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 92,920 KB
最終ジャッジ日時 2023-10-26 00:02:17
合計ジャッジ時間 18,626 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,596 KB
testcase_01 AC 38 ms
53,596 KB
testcase_02 AC 38 ms
53,596 KB
testcase_03 AC 36 ms
53,596 KB
testcase_04 AC 38 ms
53,596 KB
testcase_05 AC 39 ms
53,596 KB
testcase_06 AC 38 ms
53,596 KB
testcase_07 AC 39 ms
53,596 KB
testcase_08 AC 38 ms
55,644 KB
testcase_09 AC 41 ms
55,644 KB
testcase_10 AC 37 ms
53,596 KB
testcase_11 WA -
testcase_12 AC 37 ms
53,596 KB
testcase_13 AC 37 ms
53,596 KB
testcase_14 AC 37 ms
53,596 KB
testcase_15 AC 38 ms
53,596 KB
testcase_16 AC 37 ms
53,596 KB
testcase_17 AC 39 ms
55,644 KB
testcase_18 AC 38 ms
55,644 KB
testcase_19 AC 37 ms
53,596 KB
testcase_20 AC 38 ms
53,596 KB
testcase_21 AC 37 ms
53,596 KB
testcase_22 AC 38 ms
53,596 KB
testcase_23 AC 38 ms
53,596 KB
testcase_24 AC 38 ms
53,596 KB
testcase_25 AC 37 ms
53,596 KB
testcase_26 AC 39 ms
55,644 KB
testcase_27 AC 40 ms
55,644 KB
testcase_28 AC 1,441 ms
83,008 KB
testcase_29 AC 1,074 ms
80,576 KB
testcase_30 AC 47 ms
72,136 KB
testcase_31 AC 69 ms
75,128 KB
testcase_32 AC 41 ms
55,644 KB
testcase_33 AC 73 ms
75,128 KB
testcase_34 AC 381 ms
76,072 KB
testcase_35 AC 62 ms
75,120 KB
testcase_36 AC 54 ms
75,120 KB
testcase_37 AC 844 ms
78,764 KB
testcase_38 AC 1,229 ms
81,296 KB
testcase_39 AC 1,639 ms
84,720 KB
testcase_40 TLE -
testcase_41 AC 946 ms
78,236 KB
testcase_42 AC 357 ms
75,392 KB
testcase_43 AC 933 ms
77,208 KB
testcase_44 AC 909 ms
78,260 KB
testcase_45 AC 679 ms
76,568 KB
testcase_46 AC 639 ms
76,068 KB
testcase_47 AC 796 ms
77,172 KB
testcase_48 AC 486 ms
75,820 KB
testcase_49 AC 732 ms
77,052 KB
testcase_50 AC 39 ms
55,644 KB
testcase_51 AC 39 ms
53,596 KB
testcase_52 AC 37 ms
53,596 KB
testcase_53 AC 37 ms
53,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Base_10_to_n(X, n, R):
    X = X // (n ** R)
    if X == n:
        return 1
    else :
        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