結果
| 問題 |
No.2299 Antitypoglycemia
|
| コンテスト | |
| ユーザー |
bluemegane
|
| 提出日時 | 2023-05-13 16:05:52 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 1,061 bytes |
| コンパイル時間 | 4,086 ms |
| コンパイル使用メモリ | 109,256 KB |
| 実行使用メモリ | 26,268 KB |
| 最終ジャッジ日時 | 2024-11-29 08:23:22 |
| 合計ジャッジ時間 | 5,561 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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);
}
}
}
bluemegane