結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー convexineqconvexineq
提出日時 2021-03-05 22:16:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 178 ms / 3,000 ms
コード長 830 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 82,256 KB
実行使用メモリ 77,804 KB
最終ジャッジ日時 2024-10-07 02:29:37
合計ジャッジ時間 4,656 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
T = [0, 0, 1, 0, 2, 0, 1, 0, 2, 0]
F = [0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
dp = [[[0]*3 for _ in range(3)] for _ in range(2)]
# two , five, less
first = 1
MOD = 10**9+7
for x in map(int,s):
    ndp = [[[0]*3 for _ in range(3)] for _ in range(2)]
    if first:
        first = 0
        for j in range(1,x+1):
            ndp[int(j<x)][T[j]][F[j]] += 1
    else:
        for j in range(1,10):
            ndp[1][T[j]][F[j]] += 1

    for is_less in range(2):
        for two in range(3):
            for five in range(3):
                for j in range(1,10 if is_less else x+1):
                    ndp[is_less|int(j < x)][min(2,two+T[j])][min(2,five+F[j])] += dp[is_less][two][five]
                    ndp[is_less|int(j < x)][min(2,two+T[j])][min(2,five+F[j])] %= MOD

    dp = ndp
print((dp[0][2][2] + dp[1][2][2]) %MOD)
0