結果

問題 No.1431 東大文系数学2020第2問改
ユーザー 👑 Nachia
提出日時 2021-03-14 14:50:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,089 ms / 5,000 ms
コード長 759 bytes
コンパイル時間 4,858 ms
コンパイル使用メモリ 251,368 KB
最終ジャッジ日時 2025-01-19 16:47:18
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
using mll = atcoder::static_modint<998244353>;
#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++)

int N,M,K;
const int Z=9000000;
mll F[Z+1];
mll I[Z+1];
mll iF[Z+1];

mll C(int n,int r){ if(n<r) return 0; return F[n]*iF[r]*iF[n-r]; }

int main(){
  cin>>N>>M>>K;
  mll ans=0;
  F[0]=I[1]=iF[0]=1;
  for(int i=1; i<=N*N; i++) F[i]=F[i-1]*i;
  for(int i=2; i<=N*N; i++) I[i]=-(998244353/i*I[998244353%i]);
  for(int i=1; i<=N*N; i++) iF[i]=iF[i-1]*I[i];
  rep(X,N+1) rep(Y,N+1){
    if(X+Y<K) continue;
    mll t = C((N-X)*(N-Y),M) * C(N,X) * C(N,Y) * C(X+Y,K);
    if((X+Y-K)%2==0) ans += t; else ans-=t;
  }
  cout<<ans.val()<<endl;
  return 0;
}
0