結果

問題 No.2299 Antitypoglycemia
ユーザー startcpp
提出日時 2023-05-13 19:47:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 530 bytes
コンパイル時間 566 ms
コンパイル使用メモリ 66,432 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-29 11:21:52
合計ジャッジ時間 1,432 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

//余事象.. A or B = |A| + |B| - |A and B| (N>=2なのでA=Bか否かで場合分け)
#include <iostream>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using mint = modint998244353;

int mod = 998244353;
int n, a, b;
mint fact[200001];

void initFact(int n) {
	fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		fact[i] = i * fact[i - 1];
	}
}

int main() {
	int i;
	cin >> n >> a >> b;
	initFact(n);

	mint ans = fact[n] - 2 * fact[n - 1] + (a != b) * fact[n - 2];
	cout << ans.val() << endl;
	return 0;
}
0