結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー tcltk
提出日時 2021-09-19 14:43:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 328 ms / 3,000 ms
コード長 1,294 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 100,864 KB
最終ジャッジ日時 2024-07-01 17:52:23
合計ジャッジ時間 9,297 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """1000
# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10

MOD = 1000000007


N = input()
L = len(N)

dp = [[[[0, 0] for _ in range(3)] for _ in range(3)] for _ in range(L+1)]
dp[0][0][0][0] = 1
for i in range(1, L+1):
    dp[i][0][0][1] = 1


for i in range(L):
    for n2 in range(3):
        for n5 in range(3):
            for less in [0, 1]:
                for k in range(1, 10 if less else int(N[i])+1):
                    less_1 = less | (k < int(N[i]))
                    n2_1 = n2
                    n5_1 = n5
                    if k == 2:
                        n2_1 = min(n2+1, 2)
                    elif k == 4:
                        n2_1 = 2
                    elif k == 5:
                        n5_1 = min(n5+1, 2)
                    elif k == 6:
                        n2_1 = min(n2+1, 2)
                    elif k == 8:
                        n2_1 = 2
                    dp[i+1][n2_1][n5_1][less_1] = (dp[i+1][n2_1][n5_1][less_1] + dp[i][n2][n5][less]) % MOD

ans = sum(dp[L][2][2]) % MOD
print(ans)
0