結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー 👑 kakel-sankakel-san
提出日時 2024-01-28 21:40:09
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 255 ms / 3,000 ms
コード長 1,529 bytes
コンパイル時間 13,916 ms
コンパイル使用メモリ 158,600 KB
実行使用メモリ 189,308 KB
最終ジャッジ日時 2024-01-28 21:40:30
合計ジャッジ時間 20,437 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
32,676 KB
testcase_01 AC 76 ms
32,676 KB
testcase_02 AC 76 ms
32,676 KB
testcase_03 AC 80 ms
33,444 KB
testcase_04 AC 105 ms
32,676 KB
testcase_05 AC 79 ms
32,676 KB
testcase_06 AC 77 ms
32,676 KB
testcase_07 AC 78 ms
32,676 KB
testcase_08 AC 79 ms
32,676 KB
testcase_09 AC 81 ms
33,444 KB
testcase_10 AC 79 ms
32,676 KB
testcase_11 AC 80 ms
33,060 KB
testcase_12 AC 79 ms
33,060 KB
testcase_13 AC 76 ms
32,676 KB
testcase_14 AC 219 ms
62,372 KB
testcase_15 AC 255 ms
63,780 KB
testcase_16 AC 224 ms
63,780 KB
testcase_17 AC 224 ms
63,780 KB
testcase_18 AC 222 ms
63,780 KB
testcase_19 AC 229 ms
63,780 KB
testcase_20 AC 82 ms
33,444 KB
testcase_21 AC 86 ms
34,212 KB
testcase_22 AC 83 ms
33,828 KB
testcase_23 AC 89 ms
35,620 KB
testcase_24 AC 85 ms
34,468 KB
testcase_25 AC 87 ms
34,212 KB
testcase_26 AC 81 ms
33,188 KB
testcase_27 AC 137 ms
46,116 KB
testcase_28 AC 107 ms
38,564 KB
testcase_29 AC 91 ms
35,108 KB
testcase_30 AC 153 ms
39,972 KB
testcase_31 AC 121 ms
189,308 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (108 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.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 c = NList;
        var (n, k) = (c[0], c[1]);
        c = NList;
        var num = new List<int>();
        var clist = new List<int>();
        var dlist = new List<int>();
        var bitmax = 1;
        for (var i = 0; i < 9; ++i) if (c[i] > 0)
        {
            num.Add(i + 1);
            clist.Add(c[i]);
            if (dlist.Count == 0) dlist.Add(1);
            else dlist.Add(dlist[^1] * (clist[^2] + 1));
            bitmax *= c[i] + 1;
        }
        var dp = new long[bitmax][];
        for (var i = 0; i < dp.Length; ++i) dp[i] = new long[k];
        dp[0][0] = 1;
        for (var b = 0; b < bitmax; ++b)
        {
            for (var i = 0; i < clist.Count; ++i)
            {
                var ci = b / dlist[i] % (clist[i] + 1);
                if (ci == clist[i]) continue;
                for (var j = 0; j < k; ++j)
                {
                    var next = (j * 10 + num[i]) % k;
                    dp[b + dlist[i]][next] += dp[b][j];
                }
            }
        }
        WriteLine(dp[^1][0]);
    }
}
0