結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー omochanalomochanal
提出日時 2018-12-19 18:07:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 693 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 11,936 KB
実行使用メモリ 42,588 KB
最終ジャッジ日時 2023-10-26 00:01:08
合計ジャッジ時間 41,756 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 495 ms
42,448 KB
testcase_01 AC 472 ms
42,532 KB
testcase_02 AC 480 ms
42,532 KB
testcase_03 AC 462 ms
42,532 KB
testcase_04 AC 471 ms
42,532 KB
testcase_05 AC 465 ms
42,532 KB
testcase_06 AC 469 ms
42,532 KB
testcase_07 AC 475 ms
42,532 KB
testcase_08 AC 480 ms
42,532 KB
testcase_09 AC 465 ms
42,532 KB
testcase_10 AC 458 ms
42,532 KB
testcase_11 AC 465 ms
42,532 KB
testcase_12 AC 460 ms
42,532 KB
testcase_13 AC 463 ms
42,532 KB
testcase_14 AC 468 ms
42,532 KB
testcase_15 AC 472 ms
42,532 KB
testcase_16 AC 463 ms
42,532 KB
testcase_17 AC 471 ms
42,532 KB
testcase_18 AC 464 ms
42,532 KB
testcase_19 AC 459 ms
42,532 KB
testcase_20 AC 465 ms
42,532 KB
testcase_21 AC 475 ms
42,532 KB
testcase_22 AC 462 ms
42,532 KB
testcase_23 AC 467 ms
42,532 KB
testcase_24 AC 474 ms
42,532 KB
testcase_25 AC 472 ms
42,532 KB
testcase_26 AC 477 ms
42,532 KB
testcase_27 AC 477 ms
42,532 KB
testcase_28 AC 1,671 ms
42,532 KB
testcase_29 AC 1,361 ms
42,532 KB
testcase_30 AC 482 ms
42,532 KB
testcase_31 AC 497 ms
42,532 KB
testcase_32 AC 465 ms
42,532 KB
testcase_33 AC 504 ms
42,532 KB
testcase_34 AC 753 ms
42,532 KB
testcase_35 AC 482 ms
42,532 KB
testcase_36 AC 478 ms
42,532 KB
testcase_37 AC 1,150 ms
42,532 KB
testcase_38 AC 1,506 ms
42,532 KB
testcase_39 AC 1,829 ms
42,532 KB
testcase_40 TLE -
testcase_41 AC 1,264 ms
42,532 KB
testcase_42 AC 689 ms
42,532 KB
testcase_43 AC 1,083 ms
42,532 KB
testcase_44 AC 1,258 ms
42,532 KB
testcase_45 AC 1,017 ms
42,532 KB
testcase_46 AC 862 ms
42,532 KB
testcase_47 AC 1,155 ms
42,532 KB
testcase_48 AC 827 ms
42,532 KB
testcase_49 AC 1,049 ms
42,532 KB
testcase_50 AC 471 ms
42,532 KB
testcase_51 AC 469 ms
42,532 KB
testcase_52 AC 466 ms
42,532 KB
testcase_53 AC 467 ms
42,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy

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