結果

問題 No.2299 Antitypoglycemia
ユーザー shobonvipshobonvip
提出日時 2023-05-12 21:28:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 840 bytes
コンパイル時間 4,288 ms
コンパイル使用メモリ 262,020 KB
実行使用メモリ 7,496 KB
最終ジャッジ日時 2024-05-06 11:04:38
合計ジャッジ時間 5,425 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,492 KB
testcase_01 AC 9 ms
7,424 KB
testcase_02 AC 9 ms
7,364 KB
testcase_03 AC 9 ms
7,496 KB
testcase_04 AC 9 ms
7,424 KB
testcase_05 AC 9 ms
7,496 KB
testcase_06 AC 8 ms
7,364 KB
testcase_07 AC 8 ms
7,368 KB
testcase_08 AC 9 ms
7,364 KB
testcase_09 AC 8 ms
7,364 KB
testcase_10 AC 8 ms
7,364 KB
testcase_11 AC 9 ms
7,424 KB
testcase_12 AC 9 ms
7,368 KB
testcase_13 AC 8 ms
7,368 KB
testcase_14 AC 9 ms
7,424 KB
testcase_15 AC 8 ms
7,368 KB
testcase_16 AC 9 ms
7,496 KB
testcase_17 AC 9 ms
7,496 KB
testcase_18 AC 9 ms
7,364 KB
testcase_19 AC 9 ms
7,364 KB
testcase_20 AC 9 ms
7,492 KB
testcase_21 AC 8 ms
7,368 KB
testcase_22 AC 8 ms
7,364 KB
testcase_23 AC 8 ms
7,368 KB
testcase_24 AC 9 ms
7,492 KB
testcase_25 AC 9 ms
7,424 KB
testcase_26 AC 10 ms
7,424 KB
testcase_27 AC 8 ms
7,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

typedef modint998244353 mint;
typedef long long ll;

//defmodfact
const int COMinitMAX = 500000;
mint fact[COMinitMAX+1], factinv[COMinitMAX+1];

void modfact(){
	fact[0] = 1;
	for (int i=1; i<=COMinitMAX; i++){
		fact[i] = fact[i-1] * i;
	}
	factinv[COMinitMAX] = fact[COMinitMAX].inv();
	for (int i=COMinitMAX-1; i>=0; i--){
		factinv[i] = factinv[i+1] * (i+1);
	}
}

mint cmb(int a, int b){
	if (a<b || b<0) return mint(0);
	return fact[a]*factinv[b]*factinv[a-b];
}
//--------


int main(){
	modfact();
	int n, a, b; cin >> n >> a >> b;
	mint ans = 0;
	if (a == b){
		ans += fact[n];
		ans -= fact[n-1];
		ans -= fact[n-1];
	}else{
		ans += fact[n];
		ans -= fact[n-1];
		ans -= fact[n-1];
		ans += fact[n-2];
	}
	cout << ans.val() << endl;
}
0