結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー omochanalomochanal
提出日時 2018-12-19 17:47:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 676 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 11,964 KB
実行使用メモリ 42,588 KB
最終ジャッジ日時 2023-10-25 23:59:42
合計ジャッジ時間 38,379 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 459 ms
42,588 KB
testcase_01 AC 446 ms
42,588 KB
testcase_02 AC 444 ms
42,588 KB
testcase_03 AC 444 ms
42,588 KB
testcase_04 AC 446 ms
42,588 KB
testcase_05 AC 450 ms
42,588 KB
testcase_06 AC 449 ms
42,588 KB
testcase_07 AC 445 ms
42,588 KB
testcase_08 AC 480 ms
42,588 KB
testcase_09 AC 447 ms
42,588 KB
testcase_10 AC 445 ms
42,588 KB
testcase_11 AC 447 ms
42,588 KB
testcase_12 AC 444 ms
42,588 KB
testcase_13 AC 445 ms
42,588 KB
testcase_14 AC 446 ms
42,588 KB
testcase_15 AC 447 ms
42,588 KB
testcase_16 AC 444 ms
42,588 KB
testcase_17 AC 450 ms
42,588 KB
testcase_18 AC 447 ms
42,588 KB
testcase_19 AC 445 ms
42,588 KB
testcase_20 AC 443 ms
42,588 KB
testcase_21 AC 443 ms
42,588 KB
testcase_22 AC 446 ms
42,588 KB
testcase_23 AC 446 ms
42,588 KB
testcase_24 AC 450 ms
42,588 KB
testcase_25 AC 445 ms
42,588 KB
testcase_26 AC 447 ms
42,588 KB
testcase_27 AC 445 ms
42,588 KB
testcase_28 AC 1,646 ms
42,588 KB
testcase_29 AC 1,341 ms
42,588 KB
testcase_30 AC 454 ms
42,588 KB
testcase_31 WA -
testcase_32 AC 451 ms
42,588 KB
testcase_33 AC 484 ms
42,588 KB
testcase_34 AC 739 ms
42,588 KB
testcase_35 AC 462 ms
42,588 KB
testcase_36 AC 454 ms
42,588 KB
testcase_37 AC 1,126 ms
42,588 KB
testcase_38 AC 1,507 ms
42,588 KB
testcase_39 AC 1,805 ms
42,588 KB
testcase_40 TLE -
testcase_41 AC 1,241 ms
42,588 KB
testcase_42 AC 666 ms
42,588 KB
testcase_43 AC 1,072 ms
42,588 KB
testcase_44 AC 1,213 ms
42,588 KB
testcase_45 AC 1,000 ms
42,588 KB
testcase_46 AC 845 ms
42,588 KB
testcase_47 AC 1,099 ms
42,588 KB
testcase_48 AC 813 ms
42,588 KB
testcase_49 AC 1,029 ms
42,588 KB
testcase_50 AC 448 ms
42,588 KB
testcase_51 AC 447 ms
42,588 KB
testcase_52 WA -
testcase_53 AC 442 ms
42,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy

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

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