結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー PachicobuePachicobue
提出日時 2018-12-05 16:40:53
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 565 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 79,412 KB
最終ジャッジ日時 2023-09-26 12:03:53
合計ジャッジ時間 8,323 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,368 KB
testcase_01 AC 73 ms
71,320 KB
testcase_02 AC 75 ms
71,316 KB
testcase_03 AC 75 ms
71,128 KB
testcase_04 AC 77 ms
71,392 KB
testcase_05 AC 75 ms
71,348 KB
testcase_06 AC 77 ms
71,108 KB
testcase_07 AC 75 ms
71,476 KB
testcase_08 AC 78 ms
71,252 KB
testcase_09 AC 81 ms
71,628 KB
testcase_10 AC 73 ms
71,256 KB
testcase_11 AC 75 ms
71,516 KB
testcase_12 AC 74 ms
71,344 KB
testcase_13 AC 80 ms
71,256 KB
testcase_14 AC 78 ms
71,348 KB
testcase_15 AC 77 ms
71,596 KB
testcase_16 AC 79 ms
71,396 KB
testcase_17 AC 78 ms
71,644 KB
testcase_18 AC 80 ms
71,336 KB
testcase_19 AC 78 ms
71,120 KB
testcase_20 AC 78 ms
71,484 KB
testcase_21 AC 76 ms
71,468 KB
testcase_22 AC 80 ms
71,312 KB
testcase_23 AC 79 ms
71,252 KB
testcase_24 AC 76 ms
71,508 KB
testcase_25 AC 72 ms
71,332 KB
testcase_26 AC 77 ms
71,260 KB
testcase_27 AC 80 ms
71,624 KB
testcase_28 RE -
testcase_29 RE -
testcase_30 AC 86 ms
71,308 KB
testcase_31 AC 80 ms
71,472 KB
testcase_32 AC 78 ms
71,364 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 AC 80 ms
71,312 KB
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 87 ms
71,408 KB
testcase_43 AC 162 ms
71,888 KB
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 113 ms
71,784 KB
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 AC 71 ms
71,248 KB
testcase_51 AC 71 ms
71,132 KB
testcase_52 AC 74 ms
71,264 KB
testcase_53 AC 73 ms
71,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def power(p,n):
    if n == 0:
        return 1
    elif n%2==0:
        return power(p*p,n/2)
    else:
        return power(p,n-1)*p

B = int(input())
D = int(input(), B)
if D < B:
    print(D)
    exit(0)
inf = -1
sup = 100000
while sup-inf > 1:
    mid = (sup+inf)//2
    v = mid*power(B, mid)-(power(B,mid)-1)//(B-1)
    if v < D:
        inf = mid
    else:
        sup = mid


# print(inf,sup)
D -= inf*power(B,inf)-(power(B,inf)-1)//(B-1)
D -= 1
num = D//sup
d = D%sup
NUM = power(B,inf)+num
# print(NUM)
NUM //= power(B,inf-d)
# print("d=",d)
print(NUM%B)
0