結果

問題 No.1414 東大文系数学2021第2問改
ユーザー 👑 NachiaNachia
提出日時 2021-03-01 10:50:45
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 430 ms / 2,000 ms
コード長 622 bytes
コンパイル時間 2,021 ms
コンパイル使用メモリ 196,684 KB
実行使用メモリ 238,032 KB
最終ジャッジ日時 2024-04-14 03:37:52
合計ジャッジ時間 11,643 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,624 KB
testcase_01 AC 2 ms
7,756 KB
testcase_02 AC 408 ms
238,028 KB
testcase_03 AC 3 ms
7,748 KB
testcase_04 AC 403 ms
238,024 KB
testcase_05 AC 404 ms
238,028 KB
testcase_06 AC 407 ms
238,024 KB
testcase_07 AC 3 ms
7,756 KB
testcase_08 AC 2 ms
7,748 KB
testcase_09 AC 399 ms
238,032 KB
testcase_10 AC 405 ms
238,032 KB
testcase_11 AC 398 ms
238,028 KB
testcase_12 AC 411 ms
237,900 KB
testcase_13 AC 409 ms
238,028 KB
testcase_14 AC 430 ms
238,028 KB
testcase_15 AC 402 ms
237,904 KB
testcase_16 AC 406 ms
238,028 KB
testcase_17 AC 411 ms
237,900 KB
testcase_18 AC 405 ms
238,028 KB
testcase_19 AC 429 ms
238,028 KB
testcase_20 AC 428 ms
238,028 KB
testcase_21 AC 393 ms
237,064 KB
testcase_22 AC 3 ms
7,752 KB
testcase_23 AC 401 ms
237,900 KB
testcase_24 AC 401 ms
237,900 KB
testcase_25 AC 397 ms
238,028 KB
testcase_26 AC 401 ms
238,028 KB
権限があれば一括ダウンロードができます

ソースコード

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 && N-M+1>=r; 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