結果

問題 No.2527 H and W
ユーザー momoyuumomoyuu
提出日時 2023-11-04 22:15:23
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 292 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 3,353 ms
コンパイル使用メモリ 246,908 KB
実行使用メモリ 19,232 KB
最終ジャッジ日時 2023-11-04 22:15:36
合計ジャッジ時間 12,064 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 277 ms
19,232 KB
testcase_01 AC 277 ms
19,232 KB
testcase_02 AC 287 ms
19,232 KB
testcase_03 AC 276 ms
19,232 KB
testcase_04 AC 278 ms
19,232 KB
testcase_05 AC 277 ms
19,232 KB
testcase_06 AC 278 ms
19,232 KB
testcase_07 AC 276 ms
19,232 KB
testcase_08 AC 288 ms
19,232 KB
testcase_09 AC 277 ms
19,232 KB
testcase_10 AC 276 ms
19,232 KB
testcase_11 AC 278 ms
19,232 KB
testcase_12 AC 282 ms
19,232 KB
testcase_13 AC 285 ms
19,232 KB
testcase_14 AC 287 ms
19,232 KB
testcase_15 AC 279 ms
19,232 KB
testcase_16 AC 292 ms
19,232 KB
testcase_17 AC 289 ms
19,232 KB
testcase_18 AC 286 ms
19,232 KB
testcase_19 AC 283 ms
19,232 KB
testcase_20 AC 284 ms
19,232 KB
testcase_21 AC 287 ms
19,232 KB
testcase_22 AC 287 ms
19,232 KB
testcase_23 AC 287 ms
19,232 KB
testcase_24 AC 283 ms
19,232 KB
testcase_25 AC 285 ms
19,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;


#include<atcoder/modint>
using mint = atcoder::modint998244353;

const int mx = 2e6;
mint fac[mx+1],ifac[mx+1];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    fac[0] = 1;
    for(int i = 1;i<=mx;i++) fac[i] = fac[i-1] * i;
    for(int i = 0;i<=mx;i++) ifac[i] = fac[i].inv();

    ll h,w;
    cin>>h>>w;
    ll k;
    cin>>k;
    ll want = h * w - k;
    mint ans = 0;
    for(int i = 0;i<=h;i++){
        mint tmp = fac[h] * ifac[i] * ifac[h-i];
        ll now = w * i;
        if(now>want) continue;
        ll res = want - now;
        ll one = h - i;
        if(res%one!=0) continue;
        ll can = res / one;
        if(can>w) continue;
        tmp *= fac[w] * ifac[can] * ifac[w-can];
        ans += tmp;
    }
    cout<<ans.val()<<endl;
}
0