結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー dachengzdachengz
提出日時 2022-12-17 11:56:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 178 ms / 3,000 ms
コード長 1,061 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,292 KB
実行使用メモリ 87,680 KB
最終ジャッジ日時 2024-04-28 07:13:13
合計ジャッジ時間 4,080 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
52,480 KB
testcase_01 AC 43 ms
52,480 KB
testcase_02 AC 60 ms
61,824 KB
testcase_03 AC 42 ms
52,352 KB
testcase_04 AC 42 ms
51,968 KB
testcase_05 AC 42 ms
52,352 KB
testcase_06 AC 41 ms
52,224 KB
testcase_07 AC 41 ms
52,808 KB
testcase_08 AC 39 ms
52,460 KB
testcase_09 AC 39 ms
52,224 KB
testcase_10 AC 38 ms
52,352 KB
testcase_11 AC 39 ms
52,352 KB
testcase_12 AC 42 ms
59,136 KB
testcase_13 AC 46 ms
60,140 KB
testcase_14 AC 44 ms
59,264 KB
testcase_15 AC 48 ms
61,184 KB
testcase_16 AC 54 ms
64,384 KB
testcase_17 AC 54 ms
65,280 KB
testcase_18 AC 58 ms
66,304 KB
testcase_19 AC 49 ms
61,824 KB
testcase_20 AC 58 ms
65,792 KB
testcase_21 AC 49 ms
62,080 KB
testcase_22 AC 58 ms
66,688 KB
testcase_23 AC 60 ms
66,048 KB
testcase_24 AC 60 ms
66,048 KB
testcase_25 AC 61 ms
66,560 KB
testcase_26 AC 50 ms
61,824 KB
testcase_27 AC 56 ms
64,256 KB
testcase_28 AC 69 ms
66,048 KB
testcase_29 AC 69 ms
66,176 KB
testcase_30 AC 89 ms
75,452 KB
testcase_31 AC 67 ms
67,456 KB
testcase_32 AC 105 ms
77,700 KB
testcase_33 AC 103 ms
78,812 KB
testcase_34 AC 136 ms
84,688 KB
testcase_35 AC 139 ms
85,120 KB
testcase_36 AC 138 ms
84,764 KB
testcase_37 AC 178 ms
87,680 KB
testcase_38 AC 138 ms
85,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7

digits = [int(c) for c in input()]
digits[-1] += 1
l = len(digits)

factors = [1, 2, 4, 5, 10, 20, 25, 50, 100]
d_map1 = [0, 1, 2, 1, 4, 5, 2, 1, 4, 1, 10]
d_map2 = {1: 1, 2: 2, 4: 4, 5: 5, 8: 4, 10: 10, 16: 4, 20: 20, 25: 25, 40: 20, 50: 50, 80: 20, 100: 100, 125: 25, 200: 100, 250: 50, 400: 100, 500: 100}

ans = 0
dp = [{f: 0 for f in factors} for _ in range(l)]
dp[0][1] = 1
for i in range(1, l):
    ndp = dp[i]
    for d in range(1, 10):
        d1 = d_map1[d]
        for k, v in dp[i - 1].items():
            ndp[d_map2[k * d1]] += v
    dp[i] = {f: v % mod for f, v in dp[i].items()}
ans = sum(dp[i][100] for i in range(l)) % mod

prefix = 1
for ind, c in enumerate(digits, start=1):
    pre_dp = {f: 0 for f in factors}
    for d in range(1, c):
        pre_dp[d_map2[prefix * d_map1[d]]] += 1
    for k1, v1 in dp[l - ind].items():
        for k2, v2 in pre_dp.items():
            if k1 * k2 % 100 == 0:
                ans = (ans + v1 * v2) % mod
    if c == 0:
        break
    prefix = d_map2[prefix * d_map1[c]]
print(ans)
0