結果

問題 No.1580 I like Logarithm!
ユーザー mkawa2mkawa2
提出日時 2021-07-02 21:56:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 903 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 9,768 KB
最終ジャッジ日時 2023-09-11 21:49:24
合計ジャッジ時間 4,273 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,228 KB
testcase_01 AC 16 ms
7,692 KB
testcase_02 AC 16 ms
8,236 KB
testcase_03 AC 15 ms
7,832 KB
testcase_04 AC 15 ms
8,320 KB
testcase_05 AC 15 ms
8,276 KB
testcase_06 AC 42 ms
8,888 KB
testcase_07 AC 74 ms
9,724 KB
testcase_08 AC 17 ms
8,232 KB
testcase_09 AC 20 ms
8,200 KB
testcase_10 AC 24 ms
8,340 KB
testcase_11 AC 51 ms
9,056 KB
testcase_12 AC 56 ms
9,184 KB
testcase_13 AC 48 ms
9,020 KB
testcase_14 AC 75 ms
9,604 KB
testcase_15 AC 61 ms
9,464 KB
testcase_16 AC 16 ms
8,208 KB
testcase_17 AC 15 ms
8,180 KB
testcase_18 AC 15 ms
7,752 KB
testcase_19 AC 16 ms
8,136 KB
testcase_20 AC 15 ms
8,316 KB
testcase_21 AC 15 ms
8,328 KB
testcase_22 AC 16 ms
7,996 KB
testcase_23 AC 15 ms
8,172 KB
testcase_24 AC 15 ms
8,176 KB
testcase_25 AC 15 ms
8,108 KB
testcase_26 AC 74 ms
9,660 KB
testcase_27 AC 77 ms
9,620 KB
testcase_28 AC 75 ms
9,600 KB
testcase_29 AC 78 ms
9,608 KB
testcase_30 AC 72 ms
9,664 KB
testcase_31 AC 77 ms
9,596 KB
testcase_32 AC 76 ms
9,608 KB
testcase_33 AC 76 ms
9,700 KB
testcase_34 AC 76 ms
9,600 KB
testcase_35 AC 72 ms
9,708 KB
testcase_36 AC 71 ms
9,768 KB
testcase_37 AC 77 ms
9,608 KB
testcase_38 AC 75 ms
9,712 KB
testcase_39 AC 71 ms
9,564 KB
testcase_40 AC 79 ms
9,684 KB
testcase_41 AC 78 ms
9,700 KB
testcase_42 AC 74 ms
9,756 KB
testcase_43 AC 75 ms
9,608 KB
testcase_44 AC 76 ms
9,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
md = 10**9+7

a = II()
bb = list(map(int, SI()))
# print(b)
n = len(bb)

n2 = n-2
ans = a*(n2*pow(a, n2+1, md)-(n2+1)*pow(a, n2, md)+1)*pow(a-1, md-2, md)%md
bb[0] -= 1
bb[-1] += 1
cnt = 0
base = 1
for b in bb[::-1]:
    cnt += base*b
    cnt %= md
    base = base*a%md
ans += cnt*(n-1)
print(ans%md)
0