結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー nebukuro09nebukuro09
提出日時 2018-12-05 11:10:28
言語 Python2
(2.7.18)
結果
AC  
実行時間 339 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 6,720 KB
実行使用メモリ 6,404 KB
最終ジャッジ日時 2023-09-25 13:51:14
合計ジャッジ時間 6,196 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
6,016 KB
testcase_01 AC 13 ms
5,880 KB
testcase_02 AC 14 ms
6,052 KB
testcase_03 AC 13 ms
5,904 KB
testcase_04 AC 16 ms
5,912 KB
testcase_05 AC 16 ms
5,952 KB
testcase_06 AC 17 ms
6,088 KB
testcase_07 AC 13 ms
6,084 KB
testcase_08 AC 19 ms
6,028 KB
testcase_09 AC 19 ms
6,092 KB
testcase_10 AC 12 ms
5,860 KB
testcase_11 AC 14 ms
5,884 KB
testcase_12 AC 13 ms
5,964 KB
testcase_13 AC 16 ms
6,140 KB
testcase_14 AC 16 ms
6,000 KB
testcase_15 AC 18 ms
6,212 KB
testcase_16 AC 14 ms
6,068 KB
testcase_17 AC 18 ms
5,956 KB
testcase_18 AC 19 ms
5,944 KB
testcase_19 AC 12 ms
6,028 KB
testcase_20 AC 14 ms
6,104 KB
testcase_21 AC 13 ms
6,104 KB
testcase_22 AC 16 ms
6,052 KB
testcase_23 AC 16 ms
6,020 KB
testcase_24 AC 17 ms
6,208 KB
testcase_25 AC 14 ms
6,008 KB
testcase_26 AC 18 ms
6,252 KB
testcase_27 AC 18 ms
6,088 KB
testcase_28 AC 206 ms
6,284 KB
testcase_29 AC 208 ms
6,388 KB
testcase_30 AC 19 ms
6,148 KB
testcase_31 AC 16 ms
5,920 KB
testcase_32 AC 18 ms
6,172 KB
testcase_33 AC 19 ms
6,028 KB
testcase_34 AC 83 ms
6,208 KB
testcase_35 AC 16 ms
5,960 KB
testcase_36 AC 19 ms
6,276 KB
testcase_37 AC 140 ms
6,328 KB
testcase_38 AC 182 ms
6,312 KB
testcase_39 AC 215 ms
6,316 KB
testcase_40 AC 328 ms
6,348 KB
testcase_41 AC 339 ms
6,404 KB
testcase_42 AC 27 ms
5,972 KB
testcase_43 AC 86 ms
6,204 KB
testcase_44 AC 336 ms
6,280 KB
testcase_45 AC 212 ms
6,324 KB
testcase_46 AC 37 ms
5,988 KB
testcase_47 AC 261 ms
6,300 KB
testcase_48 AC 111 ms
6,120 KB
testcase_49 AC 205 ms
6,396 KB
testcase_50 AC 18 ms
6,036 KB
testcase_51 AC 17 ms
6,088 KB
testcase_52 AC 13 ms
6,036 KB
testcase_53 AC 12 ms
5,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

B = int(raw_input())
D = int(raw_input(), base=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)
    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