結果

問題 No.1580 I like Logarithm!
ユーザー shotoyooshotoyoo
提出日時 2021-07-02 21:34:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 526 bytes
コンパイル時間 1,375 ms
コンパイル使用メモリ 86,500 KB
実行使用メモリ 76,244 KB
最終ジャッジ日時 2023-09-11 21:23:56
合計ジャッジ時間 5,666 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,012 KB
testcase_01 AC 68 ms
71,052 KB
testcase_02 AC 70 ms
70,900 KB
testcase_03 AC 69 ms
70,996 KB
testcase_04 AC 67 ms
71,060 KB
testcase_05 AC 69 ms
70,816 KB
testcase_06 AC 120 ms
76,108 KB
testcase_07 AC 78 ms
75,992 KB
testcase_08 AC 70 ms
71,284 KB
testcase_09 AC 75 ms
76,196 KB
testcase_10 AC 75 ms
76,180 KB
testcase_11 AC 76 ms
75,848 KB
testcase_12 AC 77 ms
76,040 KB
testcase_13 AC 78 ms
76,216 KB
testcase_14 AC 77 ms
76,048 KB
testcase_15 AC 80 ms
76,136 KB
testcase_16 AC 71 ms
70,944 KB
testcase_17 AC 68 ms
71,020 KB
testcase_18 AC 70 ms
71,024 KB
testcase_19 AC 69 ms
71,076 KB
testcase_20 AC 68 ms
71,212 KB
testcase_21 AC 70 ms
71,132 KB
testcase_22 AC 72 ms
71,164 KB
testcase_23 AC 72 ms
71,008 KB
testcase_24 AC 71 ms
71,136 KB
testcase_25 AC 71 ms
70,892 KB
testcase_26 AC 79 ms
76,044 KB
testcase_27 AC 81 ms
76,224 KB
testcase_28 AC 81 ms
76,136 KB
testcase_29 AC 79 ms
76,036 KB
testcase_30 AC 80 ms
76,228 KB
testcase_31 AC 80 ms
76,244 KB
testcase_32 AC 80 ms
76,104 KB
testcase_33 AC 82 ms
76,132 KB
testcase_34 AC 79 ms
76,224 KB
testcase_35 AC 81 ms
76,040 KB
testcase_36 AC 81 ms
76,032 KB
testcase_37 AC 81 ms
76,132 KB
testcase_38 AC 80 ms
76,224 KB
testcase_39 AC 79 ms
76,192 KB
testcase_40 AC 79 ms
76,136 KB
testcase_41 AC 79 ms
76,000 KB
testcase_42 AC 80 ms
76,192 KB
testcase_43 AC 82 ms
76,048 KB
testcase_44 AC 81 ms
76,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


a = int(input())
b = input()
n = len(b)
M = 10**9+7
val = 0
v = 1
for i in range(n)[::-1]:
    val += v*int(b[i])%M
    val %= M
    v *= a
    v %= M
ans = 0
v = a-1
for i in range(1, n):
    ans += v*(i-1)%M
    ans %= M
    v *= a
    v %= M
ans += (val - pow(a, n-1, M) + 1) * (n-1)
print(ans%M)
0