結果

問題 No.372 It's automatic
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-05-12 18:59:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 4,782 ms / 6,000 ms
コード長 424 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 82,236 KB
実行使用メモリ 124,520 KB
最終ジャッジ日時 2024-04-15 15:22:57
合計ジャッジ時間 58,723 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,592 KB
testcase_01 AC 43 ms
52,460 KB
testcase_02 AC 42 ms
53,508 KB
testcase_03 AC 41 ms
53,508 KB
testcase_04 AC 4,577 ms
123,636 KB
testcase_05 AC 4,573 ms
123,576 KB
testcase_06 AC 4,718 ms
124,096 KB
testcase_07 AC 4,603 ms
123,784 KB
testcase_08 AC 4,625 ms
124,520 KB
testcase_09 AC 4,562 ms
123,792 KB
testcase_10 AC 4,585 ms
124,084 KB
testcase_11 AC 4,515 ms
123,100 KB
testcase_12 AC 4,637 ms
124,096 KB
testcase_13 AC 4,538 ms
123,580 KB
testcase_14 AC 4,581 ms
124,420 KB
testcase_15 AC 4,782 ms
124,236 KB
testcase_16 AC 50 ms
60,152 KB
testcase_17 AC 47 ms
60,704 KB
testcase_18 AC 51 ms
62,572 KB
testcase_19 AC 47 ms
61,468 KB
testcase_20 AC 51 ms
62,032 KB
testcase_21 AC 283 ms
76,144 KB
testcase_22 AC 279 ms
76,184 KB
testcase_23 AC 278 ms
75,976 KB
testcase_24 AC 282 ms
75,876 KB
testcase_25 AC 283 ms
76,200 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 = [dp2[k] for k in range(M)]

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