結果

問題 No.2527 H and W
ユーザー otoshigootoshigo
提出日時 2023-11-03 21:42:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 1,144 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 78,328 KB
実行使用メモリ 27,012 KB
最終ジャッジ日時 2023-11-03 21:42:55
合計ジャッジ時間 4,208 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
27,012 KB
testcase_01 AC 78 ms
27,012 KB
testcase_02 AC 101 ms
27,012 KB
testcase_03 AC 84 ms
27,012 KB
testcase_04 AC 96 ms
27,012 KB
testcase_05 AC 91 ms
27,012 KB
testcase_06 AC 92 ms
27,012 KB
testcase_07 AC 86 ms
27,012 KB
testcase_08 AC 95 ms
27,012 KB
testcase_09 AC 81 ms
27,012 KB
testcase_10 AC 85 ms
27,012 KB
testcase_11 AC 82 ms
27,012 KB
testcase_12 AC 93 ms
27,012 KB
testcase_13 AC 92 ms
27,012 KB
testcase_14 AC 100 ms
27,012 KB
testcase_15 AC 92 ms
27,012 KB
testcase_16 AC 94 ms
27,012 KB
testcase_17 AC 92 ms
27,012 KB
testcase_18 AC 97 ms
27,012 KB
testcase_19 AC 91 ms
27,012 KB
testcase_20 AC 91 ms
27,012 KB
testcase_21 AC 92 ms
27,012 KB
testcase_22 AC 96 ms
27,012 KB
testcase_23 AC 93 ms
27,012 KB
testcase_24 AC 92 ms
27,012 KB
testcase_25 AC 86 ms
27,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<atcoder/modint>
using namespace std;
using namespace atcoder;
using ll=long long;
using mint=modint998244353;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

const int MAX=2000010;
const ll MOD=998244353;
mint fac[MAX+1],finv[MAX+1],inv[MAX+1];

void set_fac(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2;i<=MAX;i++){
        fac[i]=fac[i-1]*i;
        inv[i]=-inv[MOD%i]*(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}

mint cmb(int n,int r){
    if (r<0||n<r)return 0;
    return fac[n]*finv[r]*finv[n-r];
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    set_fac();
    ll H,W,K;
    cin>>H>>W>>K;
    K=H*W-K;
    mint ans=0;
    for(int i=0;i<H;i++){
        if(K-W*i>=00&&(K-W*i)%(H-i)==0){
            int j=(K-W*i)/(H-i);
            ans+=cmb(H,i)*cmb(W,j);
        }
    }
    cout<<ans.val()<<"\n";
}
0