結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー tcltktcltk
提出日時 2021-09-19 15:18:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 519 ms / 3,000 ms
コード長 1,507 bytes
コンパイル時間 1,464 ms
コンパイル使用メモリ 86,884 KB
実行使用メモリ 111,140 KB
最終ジャッジ日時 2023-09-14 11:00:58
合計ジャッジ時間 16,161 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 200 ms
80,756 KB
testcase_01 AC 235 ms
84,220 KB
testcase_02 AC 252 ms
85,392 KB
testcase_03 AC 199 ms
80,772 KB
testcase_04 AC 200 ms
80,848 KB
testcase_05 AC 198 ms
80,784 KB
testcase_06 AC 196 ms
80,772 KB
testcase_07 AC 198 ms
81,132 KB
testcase_08 AC 198 ms
80,776 KB
testcase_09 AC 199 ms
80,772 KB
testcase_10 AC 203 ms
84,012 KB
testcase_11 AC 197 ms
80,964 KB
testcase_12 AC 226 ms
85,000 KB
testcase_13 AC 224 ms
84,532 KB
testcase_14 AC 224 ms
84,772 KB
testcase_15 AC 253 ms
85,440 KB
testcase_16 AC 286 ms
85,164 KB
testcase_17 AC 272 ms
85,112 KB
testcase_18 AC 286 ms
85,328 KB
testcase_19 AC 305 ms
85,960 KB
testcase_20 AC 290 ms
85,180 KB
testcase_21 AC 298 ms
85,264 KB
testcase_22 AC 276 ms
85,204 KB
testcase_23 AC 267 ms
85,328 KB
testcase_24 AC 236 ms
85,348 KB
testcase_25 AC 275 ms
85,660 KB
testcase_26 AC 291 ms
85,688 KB
testcase_27 AC 273 ms
85,984 KB
testcase_28 AC 276 ms
85,732 KB
testcase_29 AC 252 ms
85,172 KB
testcase_30 AC 267 ms
86,776 KB
testcase_31 AC 269 ms
87,520 KB
testcase_32 AC 369 ms
91,032 KB
testcase_33 AC 406 ms
98,192 KB
testcase_34 AC 517 ms
110,196 KB
testcase_35 AC 510 ms
111,140 KB
testcase_36 AC 519 ms
110,848 KB
testcase_37 AC 516 ms
110,384 KB
testcase_38 AC 431 ms
109,560 KB
権限があれば一括ダウンロードができます

ソースコード

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 = """123456
# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10

MOD = 1000000007


N = input()
L = len(N)

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

for i in range(L):
    for n2 in range(3):
        for n5 in range(3):
            for lzero in [0, 1]:
                for less in [0, 1]:
                    if lzero:
                        dp[i+1][0][0][1][1] = (dp[i+1][0][0][1][1] + dp[i][n2][n5][lzero][less]) % MOD
                    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][0][less_1] = (dp[i+1][n2_1][n5_1][0][less_1] + dp[i][n2][n5][lzero][less]) % MOD

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