結果

問題 No.2299 Antitypoglycemia
ユーザー bluemeganebluemegane
提出日時 2023-05-13 16:05:52
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,061 bytes
コンパイル時間 2,201 ms
コンパイル使用メモリ 62,988 KB
実行使用メモリ 23,112 KB
最終ジャッジ日時 2023-08-19 14:57:05
合計ジャッジ時間 5,241 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,768 KB
testcase_01 AC 56 ms
20,760 KB
testcase_02 AC 57 ms
18,804 KB
testcase_03 AC 60 ms
22,724 KB
testcase_04 AC 61 ms
20,632 KB
testcase_05 AC 60 ms
20,772 KB
testcase_06 AC 61 ms
20,768 KB
testcase_07 AC 58 ms
20,764 KB
testcase_08 AC 59 ms
20,680 KB
testcase_09 AC 60 ms
20,840 KB
testcase_10 AC 59 ms
20,776 KB
testcase_11 AC 58 ms
20,592 KB
testcase_12 AC 60 ms
20,804 KB
testcase_13 AC 62 ms
20,792 KB
testcase_14 AC 57 ms
20,808 KB
testcase_15 AC 57 ms
22,796 KB
testcase_16 AC 59 ms
22,672 KB
testcase_17 AC 58 ms
20,660 KB
testcase_18 AC 63 ms
20,888 KB
testcase_19 AC 63 ms
20,876 KB
testcase_20 AC 64 ms
23,112 KB
testcase_21 AC 62 ms
20,884 KB
testcase_22 AC 62 ms
20,800 KB
testcase_23 AC 57 ms
20,748 KB
testcase_24 AC 57 ms
20,704 KB
testcase_25 AC 58 ms
20,748 KB
testcase_26 AC 57 ms
20,808 KB
testcase_27 AC 56 ms
18,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using static System.Math;
using System;

class Modulo
{
    public const int MOD = 998244353;
    private readonly int[] m_facs;
    public int Mul(int a, int b) => (int)(BigMul(a, b) % MOD);
    public Modulo(int n)
    {
        m_facs = new int[n + 1];
        m_facs[0] = 1;
        for (int i = 1; i <= n; ++i)
            m_facs[i] = Mul(m_facs[i - 1], i);
    }
    public int Fac(int n) => m_facs[n];
}

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var a = int.Parse(line[1]);
        var b = int.Parse(line[2]);
        getAns(n, a, b);
    }
    static void getAns(int n, int a, int b)
    {
        var md = new Modulo(n);
        var ans = md.Fac(n);
        ans -= 2 * md.Fac(n - 1);
        ans %= Modulo.MOD;
        if (ans < 0) ans += Modulo.MOD;
        if (a == b) Console.WriteLine(ans);
        else
        {
            ans += md.Fac(n - 2);
            ans %= Modulo.MOD;
            Console.WriteLine(ans);
        }
    }
}
0