結果

問題 No.1846 Good Binary Matrix
ユーザー 👑 tatyamtatyam
提出日時 2021-12-14 23:59:11
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 3,584 ms
コンパイル使用メモリ 247,368 KB
実行使用メモリ 10,948 KB
最終ジャッジ日時 2023-10-01 02:16:19
合計ジャッジ時間 5,879 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,388 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 103 ms
10,872 KB
testcase_17 AC 104 ms
10,760 KB
testcase_18 AC 101 ms
10,600 KB
testcase_19 AC 99 ms
10,348 KB
testcase_20 AC 104 ms
10,948 KB
testcase_21 AC 13 ms
6,992 KB
testcase_22 AC 15 ms
7,208 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 74 ms
8,892 KB
testcase_26 AC 48 ms
6,992 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 13 ms
4,376 KB
testcase_29 AC 33 ms
5,400 KB
testcase_30 AC 79 ms
9,344 KB
testcase_31 AC 67 ms
8,708 KB
testcase_32 AC 86 ms
9,640 KB
testcase_33 AC 88 ms
10,660 KB
testcase_34 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using Modint = atcoder::modint1000000007;


int main(){
    int H, W;
    cin >> H >> W;
    vector<Modint> fac(H + 1), inv(H + 1);
    fac[0] = 1;
    for(int i = 1; i <= H; i++) fac[i] = fac[i - 1] * Modint::raw(i);
    inv[H] = fac[H].inv();
    for(int i = H; i; i--) inv[i - 1] = inv[i] * Modint::raw(i);
    auto binom = [&](int n, int r){ return fac[n] * inv[r] * inv[n - r]; };
    Modint ans = 0;
    Modint x = 1;
    for(int h = 0; h <= H; h++){
        if((h ^ H) & 1) ans -= (x - 1).pow(W) * binom(H, h);
        else ans += (x - 1).pow(W) * binom(H, h);
        x += x;
    }
    cout << ans.val() << endl;
}
0