結果

問題 No.2867 NOT FOUND 404 Again
ユーザー 👑 kakel-sankakel-san
提出日時 2024-08-30 22:24:24
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 1,937 ms / 3,000 ms
コード長 1,725 bytes
コンパイル時間 7,847 ms
コンパイル使用メモリ 168,172 KB
実行使用メモリ 214,128 KB
最終ジャッジ日時 2024-08-30 22:25:07
合計ジャッジ時間 40,758 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
30,208 KB
testcase_01 AC 55 ms
30,336 KB
testcase_02 AC 50 ms
29,568 KB
testcase_03 AC 1,871 ms
61,048 KB
testcase_04 AC 1,896 ms
61,440 KB
testcase_05 AC 1,875 ms
61,312 KB
testcase_06 AC 1,937 ms
61,048 KB
testcase_07 AC 1,900 ms
61,184 KB
testcase_08 AC 1,906 ms
61,440 KB
testcase_09 AC 1,873 ms
61,440 KB
testcase_10 AC 1,873 ms
61,056 KB
testcase_11 AC 1,848 ms
61,056 KB
testcase_12 AC 1,877 ms
61,312 KB
testcase_13 AC 1,851 ms
61,440 KB
testcase_14 AC 1,881 ms
61,312 KB
testcase_15 AC 1,840 ms
61,056 KB
testcase_16 AC 1,837 ms
61,184 KB
testcase_17 AC 1,825 ms
61,268 KB
testcase_18 AC 1,798 ms
61,184 KB
testcase_19 AC 1,875 ms
214,128 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (94 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = ReadLine();
        if (n.Length < 3)
        {
            WriteLine(int.Parse(n));
            return;
        }
        var mod = 998_244_353;
        var dp = new long[100];
        var dp1 = 1;
        var top = int.Parse(n[0..2]);
        for (var i = 0; i < top; ++i) ++dp[i];
        for (var i = 2; i < n.Length; ++i)
        {
            var ndp = new long[100];
            for (var k = 0; k < 10; ++k)
            {
                var sum = 0L;
                for (var j = 0; j < 10; ++j) sum = (sum + dp[j * 10 + k]) % mod;
                for (var j = 0; j < 10; ++j)
                {
                    if (k == 0 && j == 4) ndp[k * 10 + j] = (sum - dp[40] + mod) % mod;
                    else ndp[k * 10 + j] = sum;
                }
            }
            {
                var k = n[i - 1] - '0';
                for (var j = 0; j < n[i] - '0'; ++j)
                {
                    if (k == 0 && j == 4 && n[i - 2] == '4') continue;
                    ndp[k * 10 + j] = (ndp[k * 10 + j] + dp1) % mod;
                }
            }
            if (n[i - 2] == '4' && n[i - 1] == '0' && n[i] == '4') dp1 = 0;
            dp = ndp;
        }
        WriteLine((dp.Sum() % mod + dp1 - 1 + mod) % mod);
    }
}
0