結果

問題 No.2932 えっえっ嘘嘘嘘待って待って待って???えマジで?ほんとに?マジでやばすぎなんだけど?えっおっほんとにこんなにDPしちゃっていいんですかい???マジでやばすぎなんだけど???
ユーザー t98slider
提出日時 2024-10-12 16:27:48
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 662 bytes
コンパイル時間 4,121 ms
コンパイル使用メモリ 252,116 KB
最終ジャッジ日時 2025-02-24 18:33:40
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using mint = atcoder::modint998244353;

mint combination(long long int a, long long int b){
    mint ans = 1, div = 1;
    b = min(b, a - b);
    for(int i = 0; i < b; i++){
        ans *= a - b + i + 1;
        div *= i + 1;
    }
    ans /= div;
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, m;
    cin >> h >> w >> m;
    if(m < h + w - 1){
        cout << 0 << '\n';
        return 0;
    }
    mint ans;
    ans = combination(h + w - 2, h - 1) * combination(m, h + w - 1) * mint(m).pow(h * w - (h + w - 1));
    cout << ans.val() << '\n';
}
0