結果

問題 No.757 チャンパーノウン定数 (2)
ユーザー PachicobuePachicobue
提出日時 2018-12-05 16:32:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 527 bytes
コンパイル時間 2,156 ms
コンパイル使用メモリ 86,472 KB
実行使用メモリ 78,932 KB
最終ジャッジ日時 2023-09-26 11:46:23
合計ジャッジ時間 8,507 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,296 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 75 ms
71,312 KB
testcase_09 WA -
testcase_10 AC 72 ms
71,156 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 72 ms
71,272 KB
testcase_15 AC 72 ms
70,936 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 72 ms
71,196 KB
testcase_20 AC 73 ms
71,140 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 73 ms
71,328 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 RE -
testcase_29 RE -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 74 ms
71,136 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 AC 74 ms
71,136 KB
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 80 ms
71,156 KB
testcase_43 WA -
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 94 ms
71,024 KB
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 AC 71 ms
71,040 KB
testcase_51 AC 71 ms
71,072 KB
testcase_52 AC 74 ms
71,348 KB
testcase_53 AC 72 ms
71,264 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)
D += 1
if D <= B:
    print(D-1)
    exit(0)
inf = -1
sup = 100001
while sup-inf > 1:
    mid = (sup+inf)//2
    v = mid*power(B, mid)
    if v < D:
        inf = mid
    else:
        sup = mid


# print(inf,sup)
D -= inf*power(B,inf)
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