結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー nebukuro09nebukuro09
提出日時 2018-12-05 11:02:23
言語 PyPy2
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 661 bytes
コンパイル時間 1,033 ms
コンパイル使用メモリ 77,600 KB
実行使用メモリ 94,988 KB
最終ジャッジ日時 2023-09-25 13:42:12
合計ジャッジ時間 23,117 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
77,204 KB
testcase_01 AC 75 ms
76,152 KB
testcase_02 AC 79 ms
76,972 KB
testcase_03 AC 74 ms
76,352 KB
testcase_04 AC 78 ms
77,240 KB
testcase_05 AC 79 ms
77,232 KB
testcase_06 AC 80 ms
77,012 KB
testcase_07 AC 74 ms
76,140 KB
testcase_08 AC 82 ms
77,456 KB
testcase_09 AC 81 ms
77,136 KB
testcase_10 AC 75 ms
76,448 KB
testcase_11 AC 81 ms
77,584 KB
testcase_12 AC 75 ms
76,080 KB
testcase_13 AC 79 ms
77,460 KB
testcase_14 AC 79 ms
77,660 KB
testcase_15 AC 80 ms
77,476 KB
testcase_16 AC 76 ms
76,144 KB
testcase_17 AC 82 ms
77,456 KB
testcase_18 AC 80 ms
77,456 KB
testcase_19 AC 74 ms
76,112 KB
testcase_20 AC 79 ms
77,168 KB
testcase_21 AC 75 ms
76,408 KB
testcase_22 AC 80 ms
77,220 KB
testcase_23 AC 79 ms
77,604 KB
testcase_24 AC 80 ms
77,204 KB
testcase_25 AC 74 ms
76,140 KB
testcase_26 AC 82 ms
77,484 KB
testcase_27 AC 83 ms
77,628 KB
testcase_28 AC 1,517 ms
85,880 KB
testcase_29 AC 1,182 ms
83,888 KB
testcase_30 AC 89 ms
78,972 KB
testcase_31 AC 108 ms
78,960 KB
testcase_32 AC 81 ms
76,980 KB
testcase_33 AC 110 ms
79,136 KB
testcase_34 AC 418 ms
79,336 KB
testcase_35 AC 100 ms
79,104 KB
testcase_36 AC 89 ms
78,844 KB
testcase_37 AC 902 ms
81,788 KB
testcase_38 AC 1,296 ms
84,708 KB
testcase_39 AC 1,698 ms
87,336 KB
testcase_40 TLE -
testcase_41 AC 1,032 ms
82,184 KB
testcase_42 AC 496 ms
79,140 KB
testcase_43 AC 1,290 ms
80,716 KB
testcase_44 AC 994 ms
82,392 KB
testcase_45 AC 738 ms
80,220 KB
testcase_46 AC 891 ms
79,592 KB
testcase_47 AC 886 ms
81,016 KB
testcase_48 AC 517 ms
79,520 KB
testcase_49 AC 775 ms
80,600 KB
testcase_50 AC 81 ms
77,632 KB
testcase_51 AC 78 ms
77,628 KB
testcase_52 AC 75 ms
76,528 KB
testcase_53 AC 75 ms
75,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

B = int(raw_input())
C = raw_input()
D = 0
b = 1
for i in xrange(len(C)-1, -1, -1):
    D += b * int(C[i])
    b *= B

def f(n):
    if n == 0:
        return 0
    else:
        return n * B ** n - (B ** n - 1) / (B - 1)

def solve1():
    hi = 10**5
    lo = 0
    while hi - lo > 1:
        mid = (hi + lo) / 2
        if f(mid) >= D:
            hi = mid
        else:
            lo = mid
    return hi

def solve2():
    keta = solve1()
    x = f(keta-1)
    a = B ** (keta-1)
    b = B ** keta - 1
    hi = (D - x) / keta + ((D - x) % keta > 0)
    lo = hi - 1
    x += lo * keta
    hi += a - 1
    return hi / (B ** (keta - D + x)) % B

print solve2()
0