結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 494 ms
42,324 KB
testcase_01 AC 446 ms
42,324 KB
testcase_02 AC 447 ms
42,324 KB
testcase_03 AC 445 ms
42,324 KB
testcase_04 AC 451 ms
42,324 KB
testcase_05 AC 450 ms
42,324 KB
testcase_06 AC 451 ms
42,324 KB
testcase_07 AC 447 ms
42,324 KB
testcase_08 AC 454 ms
42,324 KB
testcase_09 AC 454 ms
42,324 KB
testcase_10 AC 443 ms
42,324 KB
testcase_11 AC 445 ms
42,324 KB
testcase_12 AC 446 ms
42,324 KB
testcase_13 AC 497 ms
42,324 KB
testcase_14 AC 511 ms
42,324 KB
testcase_15 AC 496 ms
42,324 KB
testcase_16 AC 480 ms
42,324 KB
testcase_17 AC 481 ms
42,324 KB
testcase_18 AC 490 ms
42,324 KB
testcase_19 AC 515 ms
42,324 KB
testcase_20 AC 506 ms
42,324 KB
testcase_21 AC 467 ms
42,324 KB
testcase_22 AC 496 ms
42,324 KB
testcase_23 AC 462 ms
42,324 KB
testcase_24 AC 451 ms
42,324 KB
testcase_25 AC 448 ms
42,324 KB
testcase_26 AC 454 ms
42,324 KB
testcase_27 AC 453 ms
42,324 KB
testcase_28 AC 1,793 ms
42,324 KB
testcase_29 AC 1,501 ms
42,324 KB
testcase_30 AC 460 ms
42,324 KB
testcase_31 WA -
testcase_32 AC 453 ms
42,324 KB
testcase_33 AC 484 ms
42,324 KB
testcase_34 AC 795 ms
42,324 KB
testcase_35 AC 465 ms
42,324 KB
testcase_36 AC 460 ms
42,324 KB
testcase_37 AC 1,247 ms
42,324 KB
testcase_38 AC 1,623 ms
42,324 KB
testcase_39 AC 1,963 ms
42,424 KB
testcase_40 TLE -
testcase_41 AC 1,484 ms
42,324 KB
testcase_42 AC 679 ms
42,324 KB
testcase_43 AC 1,102 ms
42,324 KB
testcase_44 AC 1,473 ms
42,324 KB
testcase_45 AC 1,165 ms
42,324 KB
testcase_46 AC 875 ms
42,324 KB
testcase_47 AC 1,311 ms
42,324 KB
testcase_48 AC 901 ms
42,324 KB
testcase_49 AC 1,183 ms
42,324 KB
testcase_50 AC 456 ms
42,324 KB
testcase_51 AC 451 ms
42,324 KB
testcase_52 WA -
testcase_53 AC 446 ms
42,324 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) - l * B ** l - 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