結果
| 問題 | No.1580 I like Logarithm! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-18 03:00:31 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 390 bytes |
| 記録 | |
| コンパイル時間 | 338 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 66,688 KB |
| 最終ジャッジ日時 | 2026-05-17 06:19:12 |
| 合計ジャッジ時間 | 3,809 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 39 |
ソースコード
MOD = 10 ** 9 + 7
a = int(input())
B = input()
l = len(B)
if l == 1:
print(0)
exit()
ans = 0
times = a - 1
for i in range(l - 1):
ans += i * times
ans %= MOD
times *= a
times %= MOD
tot = 0
times = 1
for b in B[::-1]:
tot += times * int(b)
tot %= MOD
times *= a
times %= MOD
ans += (tot - pow(a, l - 1, MOD) + 1) * (l - 1) % MOD
print(ans % MOD)