結果

問題 No.2299 Antitypoglycemia
ユーザー umezoumezo
提出日時 2023-05-12 22:23:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 1,877 ms
コンパイル使用メモリ 199,948 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2024-05-06 12:26:41
合計ジャッジ時間 3,368 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;
 
const int MOD=998244353;
const int MAX=410000;
ll fac[MAX],finv[MAX],inv[MAX];

void init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  init();
  ll n,a,b;
  cin>>n>>a>>b;
  
  ll ans=fac[n];
  ans=(ans-fac[n-1]+MOD)%MOD;
  ans=(ans-fac[n-1]+MOD)%MOD;
  if(a!=b) ans=(ans+fac[n-2])%MOD;
  cout<<ans<<endl;
  
  return 0;
}
0