結果

問題 No.372 It's automatic
ユーザー maspymaspy
提出日時 2020-03-17 02:39:34
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 491 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 44,588 KB
最終ジャッジ日時 2024-11-29 02:00:11
合計ジャッジ時間 87,143 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 TLE * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
MOD = 10**9 + 7

# %%
S = [int(x) - ord('0') for x in readline().rstrip()]
M = int(read())

# %%
add_to = np.arange(M) * 10 % M
dp = np.zeros(M, np.int64)
for x in S:
    np.add.at(dp, (add_to + x) % M, dp)
    if x != 0:
        dp[x % M] += 1
    dp %= MOD


# %%
answer = sum(x == 0 for x in S) + dp[0]
print(answer % MOD)
0