結果

問題 No.372 It's automatic
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-05-12 18:55:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 4,353 ms / 6,000 ms
コード長 407 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 82,276 KB
実行使用メモリ 128,760 KB
最終ジャッジ日時 2024-04-15 15:21:27
合計ジャッジ時間 54,391 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
52,008 KB
testcase_01 AC 43 ms
52,192 KB
testcase_02 AC 44 ms
52,180 KB
testcase_03 AC 45 ms
52,064 KB
testcase_04 AC 4,185 ms
127,464 KB
testcase_05 AC 4,222 ms
128,056 KB
testcase_06 AC 4,229 ms
128,016 KB
testcase_07 AC 4,226 ms
128,204 KB
testcase_08 AC 4,232 ms
128,760 KB
testcase_09 AC 4,217 ms
128,372 KB
testcase_10 AC 4,216 ms
127,984 KB
testcase_11 AC 4,158 ms
127,248 KB
testcase_12 AC 4,229 ms
128,452 KB
testcase_13 AC 4,249 ms
127,508 KB
testcase_14 AC 4,353 ms
128,492 KB
testcase_15 AC 4,234 ms
128,724 KB
testcase_16 AC 48 ms
59,480 KB
testcase_17 AC 48 ms
60,444 KB
testcase_18 AC 52 ms
61,824 KB
testcase_19 AC 49 ms
60,624 KB
testcase_20 AC 52 ms
61,232 KB
testcase_21 AC 264 ms
76,060 KB
testcase_22 AC 263 ms
76,124 KB
testcase_23 AC 262 ms
75,708 KB
testcase_24 AC 268 ms
76,136 KB
testcase_25 AC 265 ms
76,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod7 = 10 ** 9 + 7

s = input()
M = int(input())

dp1 = [0] * M
dp2 = [0] * M

ans = 0
for i in range(len(s)):
    for j in range(M):
        nxt = (j * 10 + int(s[i])) % M
        dp2[nxt] += dp1[j]
        dp2[nxt] %= mod7

    if s[i] != '0':
        nxt = int(s[i]) % M
        dp2[nxt] += 1
        dp2[nxt] %= mod7
    else:
        ans += 1

    dp1 = list(dp2)

ans += dp1[0]
ans %= mod7
print(ans)
0