結果

問題 No.1846 Good Binary Matrix
ユーザー SSRSSSRS
提出日時 2022-02-18 22:50:04
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 516 ms / 2,000 ms
コード長 1,208 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 202,616 KB
実行使用メモリ 18,788 KB
最終ジャッジ日時 2023-09-11 19:51:04
合計ジャッジ時間 9,010 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 516 ms
18,788 KB
testcase_17 AC 484 ms
17,816 KB
testcase_18 AC 486 ms
18,244 KB
testcase_19 AC 504 ms
18,480 KB
testcase_20 AC 516 ms
18,664 KB
testcase_21 AC 1 ms
4,384 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 226 ms
16,636 KB
testcase_24 AC 123 ms
12,624 KB
testcase_25 AC 444 ms
17,912 KB
testcase_26 AC 282 ms
16,856 KB
testcase_27 AC 467 ms
17,976 KB
testcase_28 AC 207 ms
9,832 KB
testcase_29 AC 288 ms
18,140 KB
testcase_30 AC 124 ms
6,904 KB
testcase_31 AC 59 ms
5,148 KB
testcase_32 AC 374 ms
17,304 KB
testcase_33 AC 63 ms
5,112 KB
testcase_34 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long modpow(long long a, long long b){
	long long ans = 1;
	while (b > 0){
		if (b % 2 == 1){
			ans *= a;
			ans %= MOD;
		}
		a *= a;
		a %= MOD;
		b /= 2;
	}
	return ans;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}
vector<long long> mf = {1};
vector<long long> mfi = {1};
long long modfact(int n){
	if (mf.size() > n){
		return mf[n];
	} else {
		for (int i = mf.size(); i <= n; i++){
			long long next = mf.back() * i % MOD;
			mf.push_back(next);
			mfi.push_back(modinv(next));
		}
		return mf[n];
	}
}
long long modfactinv(int n){
	if (mfi.size() > n){
		return mfi[n];
	} else {
		return modinv(modfact(n));
	}
}
long long modbinom(int n, int k){
	if (n < 0 || k < 0 || k > n){
		return 0;
	} else {
		return modfact(n) * modfactinv(k) % MOD * modfactinv(n - k) % MOD;
	}
}
int main(){
  int H, W;
  cin >> H >> W;
  long long ans = 0;
  for (int i = 0; i <= W; i++){
    long long X = 1;
    X *= modbinom(W, i);
    X %= MOD;
    long long A = modpow(2, W - i) - 1;
    X *= modpow(A, H);
    X %= MOD;
    X *= modpow(MOD - 1, i);
    X %= MOD;
    ans += X;
  }
  cout << ans % MOD << endl;
}
0