結果

問題 No.2742 Car Flow
ユーザー 👑 kakel-sankakel-san
提出日時 2024-05-30 22:17:50
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 996 bytes
コンパイル時間 16,998 ms
コンパイル使用メモリ 170,040 KB
実行使用メモリ 186,816 KB
最終ジャッジ日時 2024-05-30 22:18:15
合計ジャッジ時間 23,804 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
42,624 KB
testcase_01 AC 87 ms
42,624 KB
testcase_02 AC 85 ms
42,624 KB
testcase_03 AC 86 ms
42,752 KB
testcase_04 AC 87 ms
42,880 KB
testcase_05 AC 87 ms
42,368 KB
testcase_06 AC 86 ms
42,880 KB
testcase_07 AC 87 ms
42,612 KB
testcase_08 AC 86 ms
42,752 KB
testcase_09 AC 87 ms
42,368 KB
testcase_10 AC 79 ms
39,920 KB
testcase_11 AC 81 ms
40,192 KB
testcase_12 AC 79 ms
39,876 KB
testcase_13 AC 72 ms
35,968 KB
testcase_14 AC 72 ms
35,840 KB
testcase_15 AC 62 ms
31,488 KB
testcase_16 AC 86 ms
42,240 KB
testcase_17 AC 85 ms
42,368 KB
testcase_18 AC 62 ms
31,616 KB
testcase_19 AC 85 ms
41,984 KB
testcase_20 AC 67 ms
33,920 KB
testcase_21 AC 67 ms
33,536 KB
testcase_22 AC 81 ms
40,704 KB
testcase_23 AC 84 ms
41,600 KB
testcase_24 AC 72 ms
36,096 KB
testcase_25 AC 84 ms
41,344 KB
testcase_26 AC 86 ms
42,752 KB
testcase_27 AC 70 ms
34,048 KB
testcase_28 AC 72 ms
35,180 KB
testcase_29 AC 59 ms
30,720 KB
testcase_30 AC 81 ms
40,960 KB
testcase_31 AC 66 ms
33,528 KB
testcase_32 AC 82 ms
41,600 KB
testcase_33 AC 80 ms
40,704 KB
testcase_34 AC 69 ms
35,584 KB
testcase_35 AC 65 ms
33,280 KB
testcase_36 AC 58 ms
30,464 KB
testcase_37 AC 68 ms
34,176 KB
testcase_38 AC 81 ms
40,576 KB
testcase_39 AC 64 ms
32,000 KB
testcase_40 AC 57 ms
30,196 KB
testcase_41 AC 57 ms
30,448 KB
testcase_42 AC 57 ms
30,316 KB
testcase_43 AC 58 ms
30,448 KB
testcase_44 AC 58 ms
29,824 KB
testcase_45 AC 57 ms
30,448 KB
testcase_46 AC 57 ms
30,304 KB
testcase_47 AC 57 ms
30,208 KB
testcase_48 AC 57 ms
30,464 KB
testcase_49 AC 57 ms
30,336 KB
testcase_50 AC 57 ms
186,816 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (132 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 = NN;
        var a = NList;
        var mod = 998_244_353;
        var one = a.Count(ai => ai == 1);
        WriteLine(Exp(n, mod - 2, mod) * Math.Min(one, n - one) % mod);
    }
    static long Exp(long n, long p, int mod)
    {
        long _n = n % mod;
        var _p = p;
        var result = 1L;
        if ((_p & 1) == 1) result *= _n;
        while (_p > 0)
        {
            _n = _n * _n % mod;
            _p >>= 1;
            if ((_p & 1) == 1) result = result * _n % mod;
        }
        return result;
    }
}
0