結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー 👑 rin204rin204
提出日時 2022-02-24 19:49:57
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 717 bytes
コンパイル時間 1,077 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 79,304 KB
最終ジャッジ日時 2023-09-15 09:28:58
合計ジャッジ時間 9,253 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,420 KB
testcase_01 AC 75 ms
71,280 KB
testcase_02 AC 94 ms
76,768 KB
testcase_03 AC 73 ms
71,676 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 73 ms
71,300 KB
testcase_12 AC 82 ms
76,436 KB
testcase_13 RE -
testcase_14 AC 84 ms
76,544 KB
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 93 ms
76,972 KB
testcase_22 AC 93 ms
77,000 KB
testcase_23 RE -
testcase_24 AC 94 ms
76,928 KB
testcase_25 RE -
testcase_26 AC 92 ms
76,820 KB
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 AC 113 ms
77,688 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 AC 180 ms
77,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
MOD = 10 ** 9 + 7

N = input()
dp = {}

def f(i):
    if i == 0:
        return 0
    else:
        return gcd(i, 100)

for i in range(1, int(N[0])):
    dp[f(i)] = dp.get(f(i)) + 1

same = f(int(N[0]))
for n in N[1:]:
    n = int(n)
    ndp = {}
    for k, v in dp.items():
        for i in range(10):
            ndp[f(k * i)] = ndp.get(f(k * i), 0) + v
            ndp[f(k * i)] %= MOD
    for i in range(n):
        ndp[f(same * i)] = ndp.get(f(same * i), 0) + 1
        ndp[f(same * i)] %= MOD
    for i in range(10):
        ndp[f(i)] = ndp.get(f(i), 0) + 1
        ndp[f(i)] %= MOD
    same = f(same * n)
    dp = ndp
    
ans = dp.get(100, 0)
if same == 100:
    ans += 1
print(ans % MOD)
0