結果

問題 No.1580 I like Logarithm!
ユーザー ntuda
提出日時 2021-09-06 22:03:35
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 393 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 65,792 KB
最終ジャッジ日時 2024-12-22 20:20:22
合計ジャッジ時間 3,956 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 11 RE * 28
権限があれば一括ダウンロードができます

ソースコード

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