結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー nebukuro09nebukuro09
提出日時 2018-12-06 09:29:46
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 260 ms / 2,000 ms
コード長 570 bytes
コンパイル時間 2,091 ms
コンパイル使用メモリ 77,364 KB
実行使用メモリ 78,432 KB
最終ジャッジ日時 2023-10-12 00:16:48
合計ジャッジ時間 10,690 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
77,412 KB
testcase_01 AC 73 ms
76,288 KB
testcase_02 AC 75 ms
77,484 KB
testcase_03 AC 74 ms
76,368 KB
testcase_04 AC 76 ms
77,232 KB
testcase_05 AC 76 ms
77,144 KB
testcase_06 AC 77 ms
77,424 KB
testcase_07 AC 72 ms
76,116 KB
testcase_08 AC 79 ms
77,344 KB
testcase_09 AC 79 ms
77,392 KB
testcase_10 AC 72 ms
76,368 KB
testcase_11 AC 76 ms
77,384 KB
testcase_12 AC 73 ms
76,288 KB
testcase_13 AC 80 ms
77,360 KB
testcase_14 AC 79 ms
77,232 KB
testcase_15 AC 79 ms
77,408 KB
testcase_16 AC 73 ms
76,256 KB
testcase_17 AC 79 ms
77,548 KB
testcase_18 AC 79 ms
77,440 KB
testcase_19 AC 73 ms
76,016 KB
testcase_20 AC 76 ms
77,156 KB
testcase_21 AC 73 ms
76,116 KB
testcase_22 AC 79 ms
77,132 KB
testcase_23 AC 78 ms
77,400 KB
testcase_24 AC 79 ms
77,360 KB
testcase_25 AC 73 ms
76,120 KB
testcase_26 AC 81 ms
77,212 KB
testcase_27 AC 80 ms
77,164 KB
testcase_28 AC 176 ms
77,700 KB
testcase_29 AC 177 ms
77,380 KB
testcase_30 AC 80 ms
77,468 KB
testcase_31 AC 76 ms
76,556 KB
testcase_32 AC 78 ms
77,468 KB
testcase_33 AC 78 ms
77,180 KB
testcase_34 AC 114 ms
77,184 KB
testcase_35 AC 73 ms
76,292 KB
testcase_36 AC 78 ms
77,416 KB
testcase_37 AC 147 ms
77,412 KB
testcase_38 AC 166 ms
77,252 KB
testcase_39 AC 184 ms
77,636 KB
testcase_40 AC 247 ms
77,976 KB
testcase_41 AC 260 ms
77,984 KB
testcase_42 AC 77 ms
77,392 KB
testcase_43 AC 94 ms
77,396 KB
testcase_44 AC 257 ms
78,432 KB
testcase_45 AC 179 ms
77,592 KB
testcase_46 AC 77 ms
77,228 KB
testcase_47 AC 212 ms
77,684 KB
testcase_48 AC 131 ms
77,484 KB
testcase_49 AC 178 ms
77,280 KB
testcase_50 AC 79 ms
77,356 KB
testcase_51 AC 78 ms
77,564 KB
testcase_52 AC 75 ms
76,116 KB
testcase_53 AC 72 ms
76,372 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