結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー dachengzdachengz
提出日時 2022-12-17 11:53:15
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,057 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 87,936 KB
最終ジャッジ日時 2024-04-28 07:11:36
合計ジャッジ時間 4,113 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,480 KB
testcase_01 AC 40 ms
52,352 KB
testcase_02 AC 51 ms
62,464 KB
testcase_03 AC 39 ms
52,352 KB
testcase_04 RE -
testcase_05 AC 40 ms
52,352 KB
testcase_06 AC 40 ms
52,096 KB
testcase_07 RE -
testcase_08 AC 40 ms
52,276 KB
testcase_09 AC 39 ms
52,480 KB
testcase_10 RE -
testcase_11 AC 40 ms
52,608 KB
testcase_12 AC 46 ms
59,520 KB
testcase_13 AC 47 ms
60,160 KB
testcase_14 AC 44 ms
59,264 KB
testcase_15 AC 49 ms
61,312 KB
testcase_16 AC 57 ms
64,384 KB
testcase_17 AC 57 ms
64,768 KB
testcase_18 AC 59 ms
65,664 KB
testcase_19 AC 50 ms
61,568 KB
testcase_20 RE -
testcase_21 AC 51 ms
61,952 KB
testcase_22 AC 58 ms
66,048 KB
testcase_23 AC 58 ms
66,432 KB
testcase_24 AC 58 ms
65,920 KB
testcase_25 AC 62 ms
66,560 KB
testcase_26 AC 51 ms
62,208 KB
testcase_27 AC 56 ms
63,616 KB
testcase_28 AC 60 ms
66,048 KB
testcase_29 RE -
testcase_30 AC 77 ms
74,880 KB
testcase_31 AC 61 ms
67,712 KB
testcase_32 AC 93 ms
77,568 KB
testcase_33 AC 90 ms
78,492 KB
testcase_34 AC 121 ms
84,516 KB
testcase_35 AC 122 ms
84,756 KB
testcase_36 AC 125 ms
84,992 KB
testcase_37 AC 163 ms
87,936 KB
testcase_38 AC 122 ms
84,508 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]
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