結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー tcltktcltk
提出日時 2021-09-19 14:43:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 396 ms / 3,000 ms
コード長 1,294 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 96,128 KB
最終ジャッジ日時 2023-09-14 10:20:44
合計ジャッジ時間 12,798 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 209 ms
81,212 KB
testcase_01 AC 208 ms
81,024 KB
testcase_02 AC 250 ms
85,328 KB
testcase_03 AC 210 ms
81,200 KB
testcase_04 AC 208 ms
80,960 KB
testcase_05 AC 210 ms
81,432 KB
testcase_06 AC 202 ms
80,952 KB
testcase_07 AC 209 ms
80,796 KB
testcase_08 AC 209 ms
81,460 KB
testcase_09 AC 207 ms
81,036 KB
testcase_10 AC 210 ms
80,816 KB
testcase_11 AC 208 ms
81,436 KB
testcase_12 AC 222 ms
84,260 KB
testcase_13 AC 224 ms
84,364 KB
testcase_14 AC 227 ms
84,396 KB
testcase_15 AC 237 ms
84,440 KB
testcase_16 AC 243 ms
85,224 KB
testcase_17 AC 243 ms
85,220 KB
testcase_18 AC 246 ms
85,108 KB
testcase_19 AC 249 ms
85,332 KB
testcase_20 AC 254 ms
85,364 KB
testcase_21 AC 264 ms
85,208 KB
testcase_22 AC 262 ms
85,388 KB
testcase_23 AC 258 ms
85,280 KB
testcase_24 AC 233 ms
84,712 KB
testcase_25 AC 260 ms
85,088 KB
testcase_26 AC 263 ms
85,408 KB
testcase_27 AC 256 ms
85,300 KB
testcase_28 AC 266 ms
85,056 KB
testcase_29 AC 255 ms
85,248 KB
testcase_30 AC 260 ms
85,740 KB
testcase_31 AC 268 ms
85,852 KB
testcase_32 AC 326 ms
88,008 KB
testcase_33 AC 314 ms
90,476 KB
testcase_34 AC 390 ms
95,604 KB
testcase_35 AC 380 ms
95,768 KB
testcase_36 AC 396 ms
96,128 KB
testcase_37 AC 384 ms
95,904 KB
testcase_38 AC 336 ms
95,820 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 = """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