結果

問題 No.1407 Kindness
ユーザー 小野寺健小野寺健
提出日時 2021-05-23 09:56:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 613 ms / 2,000 ms
コード長 326 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 22,784 KB
最終ジャッジ日時 2024-04-19 20:28:57
合計ジャッジ時間 9,331 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,880 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 27 ms
10,880 KB
testcase_03 AC 27 ms
10,752 KB
testcase_04 AC 26 ms
10,752 KB
testcase_05 AC 27 ms
10,880 KB
testcase_06 AC 27 ms
10,752 KB
testcase_07 AC 25 ms
10,752 KB
testcase_08 AC 26 ms
10,880 KB
testcase_09 AC 26 ms
10,880 KB
testcase_10 AC 25 ms
10,752 KB
testcase_11 AC 26 ms
10,752 KB
testcase_12 AC 549 ms
21,504 KB
testcase_13 AC 134 ms
13,184 KB
testcase_14 AC 166 ms
13,952 KB
testcase_15 AC 503 ms
20,608 KB
testcase_16 AC 315 ms
16,896 KB
testcase_17 AC 222 ms
15,104 KB
testcase_18 AC 207 ms
14,720 KB
testcase_19 AC 466 ms
19,456 KB
testcase_20 AC 384 ms
18,176 KB
testcase_21 AC 51 ms
11,264 KB
testcase_22 AC 64 ms
11,648 KB
testcase_23 AC 354 ms
17,792 KB
testcase_24 AC 613 ms
22,656 KB
testcase_25 AC 202 ms
14,720 KB
testcase_26 AC 286 ms
16,512 KB
testcase_27 AC 57 ms
11,520 KB
testcase_28 AC 490 ms
20,352 KB
testcase_29 AC 39 ms
11,136 KB
testcase_30 AC 548 ms
21,376 KB
testcase_31 AC 135 ms
13,440 KB
testcase_32 AC 478 ms
22,144 KB
testcase_33 AC 178 ms
14,848 KB
testcase_34 AC 365 ms
19,328 KB
testcase_35 AC 150 ms
14,208 KB
testcase_36 AC 39 ms
11,136 KB
testcase_37 AC 604 ms
22,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M = 1000000007

N = input()
n = len(N)
DP = [[0] * 2 for _ in range(n+1)]
DP[0][1] = 1

for i in range(n):
    j = int(N[i])
    DP[i+1][0] = (DP[i][0] + (DP[i][1] * sum(list(range(j)))) * pow(45, n-i-1, M) + (pow(45, n-i-1, M) if i != n-1 else 0)) % M
    DP[i+1][1] = (DP[i][1] * j) % M
    
print((DP[n][0] + DP[n][1]) % M)
0