結果

問題 No.372 It's automatic
ユーザー convexineqconvexineq
提出日時 2021-02-01 22:04:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,845 ms / 6,000 ms
コード長 275 bytes
コンパイル時間 534 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 260,004 KB
最終ジャッジ日時 2023-09-12 10:52:02
合計ジャッジ時間 25,162 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,584 KB
testcase_01 AC 72 ms
71,504 KB
testcase_02 AC 72 ms
71,132 KB
testcase_03 AC 71 ms
71,544 KB
testcase_04 AC 1,813 ms
176,332 KB
testcase_05 AC 1,842 ms
241,488 KB
testcase_06 AC 1,836 ms
249,172 KB
testcase_07 AC 1,828 ms
243,112 KB
testcase_08 AC 1,823 ms
179,492 KB
testcase_09 AC 1,837 ms
240,368 KB
testcase_10 AC 1,829 ms
249,328 KB
testcase_11 AC 1,845 ms
260,004 KB
testcase_12 AC 1,813 ms
181,176 KB
testcase_13 AC 1,828 ms
212,620 KB
testcase_14 AC 1,800 ms
169,664 KB
testcase_15 AC 1,840 ms
192,872 KB
testcase_16 AC 73 ms
76,072 KB
testcase_17 AC 73 ms
75,944 KB
testcase_18 AC 74 ms
75,892 KB
testcase_19 AC 75 ms
75,892 KB
testcase_20 AC 75 ms
75,916 KB
testcase_21 AC 162 ms
77,212 KB
testcase_22 AC 160 ms
77,192 KB
testcase_23 AC 160 ms
77,136 KB
testcase_24 AC 160 ms
76,972 KB
testcase_25 AC 165 ms
77,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
m = int(input())
MOD = 10**9+7
dp = [0]*m
dp[0] = 1
for i in s:
    i = int(i)
    ndp = dp[:]
    for j in range(m):
        nj = (j*10+i)%m
        ndp[nj] += dp[j]
        ndp[nj] %= MOD
    if i == 0: ndp[0] -= 1
    dp = ndp
print((dp[0]+s.count("0")-1)%MOD)
0