結果
問題 | No.1846 Good Binary Matrix |
ユーザー |
|
提出日時 | 2022-03-14 21:05:03 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 422 ms / 2,000 ms |
コード長 | 557 bytes |
コンパイル時間 | 2,965 ms |
コンパイル使用メモリ | 248,896 KB |
実行使用メモリ | 7,184 KB |
最終ジャッジ日時 | 2024-09-21 09:13:34 |
合計ジャッジ時間 | 8,689 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using namespace std; using Mint = atcoder::modint1000000007; int main() { int H, W; cin >> H >> W; vector<Mint> fact(H + 1); fact[0] = 1; for (int i = 1; i <= H; i++) fact[i] = i * fact[i - 1]; auto C = [&](int N, int r) { return fact[N] / (fact[r] * fact[N - r]); }; Mint ans = 0; for (int r = 0; r <= H; r++) ans += Mint(-1).pow(r) * C(H, r) * (-Mint(2).pow(r) + 1).pow(W); ans *= Mint(-1).pow(H + W); cout << ans.val() << endl; }