結果

問題 No.1580 I like Logarithm!
ユーザー ntudantuda
提出日時 2021-09-06 22:03:35
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 393 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 79,508 KB
最終ジャッジ日時 2023-08-24 13:02:21
合計ジャッジ時間 7,924 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,316 KB
testcase_01 AC 71 ms
71,436 KB
testcase_02 AC 72 ms
71,444 KB
testcase_03 AC 72 ms
71,560 KB
testcase_04 AC 72 ms
71,544 KB
testcase_05 AC 72 ms
71,548 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 71 ms
71,652 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 71 ms
71,440 KB
testcase_17 AC 73 ms
71,440 KB
testcase_18 AC 72 ms
71,452 KB
testcase_19 AC 73 ms
71,160 KB
testcase_20 AC 72 ms
71,420 KB
testcase_21 AC 72 ms
71,492 KB
testcase_22 AC 71 ms
71,380 KB
testcase_23 AC 72 ms
71,620 KB
testcase_24 AC 71 ms
71,184 KB
testcase_25 AC 71 ms
71,680 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

A = int(input())
B = int(input())
B= int(str(B),A)
x = 1
j = A
ans = 0
mod = 10 ** 9 + 7

def check(x):
    return pow(A,x) <= B

lb = 0
ub = 10 ** 5 + 10

while ub - lb > 1:
    mid = (ub + lb) // 2
    if check(mid):
        lb = mid
    else:
        ub = mid

for i in range(lb+1):
    ans = (ans + (A-1) * x * i) % mod
    x = (x * A) % mod
ans = (ans + (B - x + 1) * i) % mod

print(ans)
0