結果

問題 No.2867 NOT FOUND 404 Again
ユーザー miya145592miya145592
提出日時 2024-08-30 22:33:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,872 ms / 3,000 ms
コード長 1,115 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 78,552 KB
最終ジャッジ日時 2024-08-30 22:33:53
合計ジャッジ時間 27,447 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,892 KB
testcase_01 AC 34 ms
52,896 KB
testcase_02 AC 34 ms
52,372 KB
testcase_03 AC 1,451 ms
78,260 KB
testcase_04 AC 1,435 ms
78,172 KB
testcase_05 AC 1,472 ms
78,544 KB
testcase_06 AC 1,464 ms
78,532 KB
testcase_07 AC 1,458 ms
78,380 KB
testcase_08 AC 1,656 ms
78,376 KB
testcase_09 AC 1,440 ms
78,360 KB
testcase_10 AC 1,482 ms
78,140 KB
testcase_11 AC 1,623 ms
78,228 KB
testcase_12 AC 1,432 ms
78,288 KB
testcase_13 AC 1,682 ms
78,252 KB
testcase_14 AC 1,512 ms
78,220 KB
testcase_15 AC 1,504 ms
78,176 KB
testcase_16 AC 1,531 ms
78,144 KB
testcase_17 AC 1,535 ms
78,552 KB
testcase_18 AC 1,209 ms
77,868 KB
testcase_19 AC 1,872 ms
77,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
MOD = 998244353
N = input().strip()
L = len(N)
dp = [[0 for _ in range(2)] for _ in range(3)]
dp[0][0] = 1
for i in range(L):
    ndp = [[0 for _ in range(2)] for _ in range(3)]
    for j in range(3):
        # 0
        for k in range(int(N[i])+1):
            if j==2 and k==4:
                continue
            if j==1 and k==0:
                nj = 2
            elif k==4:
                nj = 1
            else:
                nj = 0
            if k==int(N[i]):
                ndp[nj][0] += dp[j][0]
                ndp[nj][0] %= MOD
            else:
                ndp[nj][1] += dp[j][0]
                ndp[nj][1] %= MOD
        # 1
        for k in range(10):
            if j==2 and k==4:
                continue
            if j==1 and k==0:
                nj = 2
            elif k==4:
                nj = 1
            else:
                nj = 0
            ndp[nj][1] += dp[j][1]
            ndp[nj][1] %= MOD
    dp = ndp
    #print(dp)
ans = 0
for i in range(3):
    for j in range(2):
        ans += dp[i][j]
        ans %= MOD
print((ans-1)%MOD)
0