結果

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
mint f[9000090], invf[9000090];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i;
    invf[n]=f[n].inv();
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1);
}
mint comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]*invf[x-y];
}
int main()
{
    int n, m, k;
    cin>>n>>m>>k;
    fac(max(n*n, 2*n));
    mint ans=0;
    for(int a=0; a<=n; a++){
        for(int b=0; b<=n; b++){
            // for(int z=0; z<=n; z++){
            //     mint w=comb(a*b, m)*comb(n-z, a)*comb(n-k+z, b)*comb(n, z)*comb(n, k-z);
            //     if((k+a+b)&1) ans-=w;
            //     else ans+=w;
            // }
            mint z=comb(a*b, m)*f[n]*f[n]*invf[a]*invf[b]*invf[n-a]*invf[n-b]*comb(2*n-a-b, k);
            if((k+a+b)&1) ans-=z;
            else ans+=z;
        }
    }
    cout<<ans.val()<<endl;
    return 0;
}
0