結果

問題 No.1691 Badugi
ユーザー chocoruskchocorusk
提出日時 2021-09-24 23:14:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,895 bytes
コンパイル時間 3,568 ms
コンパイル使用メモリ 190,396 KB
実行使用メモリ 19,168 KB
最終ジャッジ日時 2023-09-18 22:19:26
合計ジャッジ時間 4,788 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
19,048 KB
testcase_01 AC 12 ms
19,128 KB
testcase_02 AC 12 ms
19,168 KB
testcase_03 AC 12 ms
19,132 KB
testcase_04 AC 12 ms
19,052 KB
testcase_05 AC 12 ms
19,000 KB
testcase_06 AC 12 ms
19,164 KB
testcase_07 AC 12 ms
19,020 KB
testcase_08 AC 12 ms
19,036 KB
testcase_09 AC 12 ms
19,072 KB
testcase_10 AC 12 ms
19,100 KB
testcase_11 AC 12 ms
19,080 KB
testcase_12 AC 12 ms
18,992 KB
testcase_13 AC 12 ms
18,992 KB
testcase_14 AC 12 ms
19,000 KB
testcase_15 AC 12 ms
19,040 KB
testcase_16 AC 12 ms
19,052 KB
testcase_17 AC 12 ms
19,052 KB
testcase_18 AC 12 ms
19,028 KB
testcase_19 AC 13 ms
19,084 KB
権限があれば一括ダウンロードができます

ソースコード

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