結果
問題 |
No.372 It's automatic
|
ユーザー |
![]() |
提出日時 | 2016-05-14 03:20:26 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 5,337 ms / 6,000 ms |
コード長 | 1,056 bytes |
コンパイル時間 | 218 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 262,168 KB |
最終ジャッジ日時 | 2024-10-06 01:25:58 |
合計ジャッジ時間 | 64,713 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
def main(S, M): MOD = 10 ** 9 + 7 remainder = [] for i in range(0, M): remainder.append(( (i * 10) % M, (i * 10 + 1) % M, (i * 10 + 2) % M, (i * 10 + 3) % M, (i * 10 + 4) % M, (i * 10 + 5) % M, (i * 10 + 6) % M, (i * 10 + 7) % M, (i * 10 + 8) % M, (i * 10 + 9) % M )) dp = [0] * M dp[0] = 1 zeros = 0 for s in S: nex = [0] * M si = int(s) for m in range(0, M): nex[m] += dp[m] if nex[m] >= MOD: nex[m] -= MOD r = remainder[m][si] nex[r] += dp[m] if m == 0 and si == 0: zeros += 1 nex[r] -= 1 if nex[r] < 0: nex[r] += MOD if nex[r] >= MOD: nex[r] -= MOD dp = nex print((dp[0] + zeros - 1 + MOD) % MOD) if __name__ == "__main__": S = input() M = int(input()) main(S, M)