結果

問題 No.2867 NOT FOUND 404 Again
ユーザー detteiuu
提出日時 2024-08-30 23:52:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,648 ms / 3,000 ms
コード長 815 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 82,092 KB
実行使用メモリ 78,800 KB
最終ジャッジ日時 2024-08-30 23:52:27
合計ジャッジ時間 18,603 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
L = len(N)

MOD = 998244353
now = [[0]*3 for _ in range(2)]
now[0][0] = 1
for i in range(L):
    nex = [[0]*3 for _ in range(2)]
    for small in range(2):
        for j in range(3):
            if now[small][j] == 0:
                continue
            for k in range(10 if small else int(N[i])+1):
                if j == 2 and k == 4:
                    continue
                if j == 0 and k == 4 or j == 1 and k == 0:
                    nex[small or k<int(N[i])][j+1] += now[small][j]
                    nex[small or k<int(N[i])][j+1] %= MOD
                else:
                    nex[small or k<int(N[i])][1 if k == 4 else 0] += now[small][j]
                    nex[small or k<int(N[i])][1 if k == 4 else 0] %= MOD
    now = [n[:] for n in nex[:]]

print((sum(now[0])+sum(now[1])-1)%MOD)
0