結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー nebukuro09nebukuro09
提出日時 2018-12-05 11:01:20
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 661 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 6,696 KB
実行使用メモリ 7,100 KB
最終ジャッジ日時 2023-09-25 13:40:19
合計ジャッジ時間 29,275 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
6,796 KB
testcase_01 AC 19 ms
6,132 KB
testcase_02 AC 96 ms
6,328 KB
testcase_03 AC 29 ms
6,464 KB
testcase_04 AC 162 ms
6,752 KB
testcase_05 AC 158 ms
6,628 KB
testcase_06 AC 219 ms
6,808 KB
testcase_07 AC 33 ms
6,668 KB
testcase_08 AC 267 ms
6,820 KB
testcase_09 AC 251 ms
6,888 KB
testcase_10 AC 19 ms
6,124 KB
testcase_11 AC 96 ms
6,452 KB
testcase_12 AC 28 ms
6,424 KB
testcase_13 AC 163 ms
6,596 KB
testcase_14 AC 158 ms
6,584 KB
testcase_15 AC 218 ms
6,632 KB
testcase_16 AC 33 ms
6,784 KB
testcase_17 AC 265 ms
6,808 KB
testcase_18 AC 252 ms
6,864 KB
testcase_19 AC 20 ms
6,252 KB
testcase_20 AC 96 ms
6,432 KB
testcase_21 AC 29 ms
6,332 KB
testcase_22 AC 162 ms
6,596 KB
testcase_23 AC 158 ms
6,540 KB
testcase_24 AC 218 ms
6,636 KB
testcase_25 AC 34 ms
6,672 KB
testcase_26 AC 266 ms
6,776 KB
testcase_27 AC 252 ms
6,844 KB
testcase_28 AC 1,935 ms
6,852 KB
testcase_29 AC 1,589 ms
7,048 KB
testcase_30 AC 260 ms
6,880 KB
testcase_31 AC 67 ms
6,728 KB
testcase_32 AC 266 ms
6,812 KB
testcase_33 AC 146 ms
6,584 KB
testcase_34 AC 676 ms
6,940 KB
testcase_35 AC 58 ms
6,840 KB
testcase_36 AC 229 ms
6,796 KB
testcase_37 AC 1,248 ms
6,948 KB
testcase_38 AC 1,707 ms
6,876 KB
testcase_39 TLE -
testcase_40 TLE -
testcase_41 AC 1,506 ms
7,100 KB
testcase_42 AC 383 ms
6,376 KB
testcase_43 AC 1,007 ms
6,632 KB
testcase_44 AC 1,482 ms
7,004 KB
testcase_45 AC 1,049 ms
6,776 KB
testcase_46 AC 679 ms
6,480 KB
testcase_47 AC 1,269 ms
6,996 KB
testcase_48 AC 694 ms
6,588 KB
testcase_49 AC 1,107 ms
6,984 KB
testcase_50 AC 266 ms
6,680 KB
testcase_51 AC 217 ms
6,812 KB
testcase_52 AC 29 ms
6,404 KB
testcase_53 AC 19 ms
6,156 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
    hi += a - 1
    return hi / (B ** (keta - D + x)) % B

print solve2()
0