結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー nebukuro09nebukuro09
提出日時 2018-12-05 10:59:49
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 672 bytes
コンパイル時間 913 ms
コンパイル使用メモリ 77,668 KB
実行使用メモリ 97,624 KB
最終ジャッジ日時 2023-09-25 13:37:59
合計ジャッジ時間 26,369 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
78,760 KB
testcase_01 AC 75 ms
76,288 KB
testcase_02 AC 120 ms
77,660 KB
testcase_03 AC 77 ms
77,276 KB
testcase_04 AC 161 ms
78,556 KB
testcase_05 AC 160 ms
79,340 KB
testcase_06 AC 191 ms
79,952 KB
testcase_07 AC 78 ms
78,324 KB
testcase_08 AC 211 ms
80,060 KB
testcase_09 AC 204 ms
80,492 KB
testcase_10 AC 73 ms
76,292 KB
testcase_11 AC 121 ms
77,684 KB
testcase_12 AC 75 ms
77,324 KB
testcase_13 AC 159 ms
78,764 KB
testcase_14 AC 160 ms
79,444 KB
testcase_15 AC 189 ms
80,136 KB
testcase_16 AC 77 ms
78,328 KB
testcase_17 AC 210 ms
80,264 KB
testcase_18 AC 207 ms
80,496 KB
testcase_19 AC 74 ms
76,444 KB
testcase_20 AC 120 ms
77,768 KB
testcase_21 AC 79 ms
77,344 KB
testcase_22 AC 160 ms
78,304 KB
testcase_23 AC 161 ms
79,364 KB
testcase_24 AC 190 ms
79,948 KB
testcase_25 AC 78 ms
78,612 KB
testcase_26 AC 214 ms
80,392 KB
testcase_27 AC 205 ms
80,676 KB
testcase_28 AC 1,557 ms
87,808 KB
testcase_29 AC 1,227 ms
87,068 KB
testcase_30 AC 212 ms
82,100 KB
testcase_31 AC 108 ms
80,032 KB
testcase_32 AC 213 ms
80,352 KB
testcase_33 AC 156 ms
79,768 KB
testcase_34 AC 535 ms
83,092 KB
testcase_35 AC 99 ms
79,724 KB
testcase_36 AC 198 ms
81,096 KB
testcase_37 AC 1,001 ms
84,684 KB
testcase_38 AC 1,376 ms
86,692 KB
testcase_39 AC 1,761 ms
89,180 KB
testcase_40 TLE -
testcase_41 AC 1,134 ms
84,772 KB
testcase_42 AC 489 ms
79,008 KB
testcase_43 AC 1,277 ms
81,988 KB
testcase_44 AC 1,083 ms
85,648 KB
testcase_45 AC 795 ms
81,664 KB
testcase_46 AC 859 ms
80,096 KB
testcase_47 AC 912 ms
83,704 KB
testcase_48 AC 538 ms
79,728 KB
testcase_49 AC 802 ms
82,468 KB
testcase_50 AC 208 ms
80,776 KB
testcase_51 AC 187 ms
79,688 KB
testcase_52 AC 76 ms
77,180 KB
testcase_53 AC 74 ms
76,508 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**6
    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
    s = []
    hi += a - 1
    return hi / (B ** (keta - D + x)) % B

print solve2()
0