結果

問題 No.1691 Badugi
ユーザー chocoruskchocorusk
提出日時 2021-09-24 23:14:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 1,895 bytes
コンパイル時間 3,343 ms
コンパイル使用メモリ 183,892 KB
最終ジャッジ日時 2025-01-24 17:44:22
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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[2000010], invf[2000010];
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 n, m, k;
int main()
{
    cin>>n>>m>>k;
    fac(500000);
    auto calc=[&](int n, int m, int k){
        if(k<0) return mint(0);
        return comb(n, k)*f[m]*invf[m-k];
    };
    mint ans=n*comb(m, 3)*calc(n-1, m-3, k-3)+m*comb(n, 3)*calc(m-1, n-3, k-3)+comb(n, 2)*comb(m, 2)*comb(m-2, 2)*calc(n-2, m-4, k-4)+comb(m, 2)*comb(n, 2)*comb(n-2, 2)*calc(m-2, n-4, k-4)+n*comb(m, 2)*(m-2)*comb(n-1, 2)*calc(n-3, m-3, k-4)+comb(n, 2)*comb(m, 3)*2*3*calc(n-2, m-3, k-4)+comb(m, 2)*comb(n, 3)*2*3*calc(m-2, n-3, k-4)+comb(n, 2)*comb(m, 2)*2*2*(n-2)*comb(m-2, 2)*calc(n-3, m-4, k-5)+comb(n, 2)*comb(m, 2)*2*2*(m-2)*comb(n-2, 2)*calc(m-3, n-4, k-5)+comb(n, 2)*comb(m, 3)*2*3*calc(n-2, m-3, k-4)+comb(m, 2)*comb(n, 3)*2*3*calc(m-2, n-3, k-4)+comb(n, 2)*comb(n-2, 2)*comb(m, 2)*comb(m-2, 2)*8*calc(n-4, m-4, k-6)+comb(n, 3)*comb(m, 3)*3*3*2*calc(n-3, m-3, k-5)*2+comb(n, 2)*comb(m, 2)*calc(n-2, m-2, k-4)+comb(n, 3)*comb(m, 3)*6*6*calc(n-3, m-3, k-5);
    cout<<ans.val()<<endl;
    return 0;
}
0