結果

問題 No.1414 東大文系数学2021第2問改
ユーザー 👑 NachiaNachia
提出日時 2021-03-01 10:49:42
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 610 bytes
コンパイル時間 2,228 ms
コンパイル使用メモリ 196,416 KB
実行使用メモリ 238,028 KB
最終ジャッジ日時 2024-04-14 03:37:14
合計ジャッジ時間 9,110 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

const ull m=998244353;
const int Z=10000000;
ull F[Z+1],I[Z+1],iF[Z+1];
ull C(int n,int r){ return F[n]*iF[r]%m*iF[n-r]%m; }

int main(){
  int N,M,K; cin>>N>>M>>K;
  F[0]=I[1]=iF[0]=1;
  for(int i=1; i<=N; i++) F[i]=F[i-1]*i%m;
  for(int i=2; i<=N; i++) I[i]=m-m/i*I[m%i]%m;
  for(int i=1; i<=N; i++) iF[i]=iF[i-1]*I[i]%m;
  ull ans=C(N,M), cof=m-1;
  for(int r=0; M>=r*K; r++){ ans=(ans+C(N-M+1,r)*C(N-r*K,M-r*K)%m*cof)%m; cof=m-cof; }
  cout<<ans<<endl;
  return 0;
}
0