結果

問題 No.1846 Good Binary Matrix
ユーザー Drice27149Drice27149
提出日時 2022-02-18 23:16:58
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 823 ms / 2,000 ms
コード長 1,081 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 70,932 KB
実行使用メモリ 10,988 KB
最終ジャッジ日時 2023-09-11 20:05:59
合計ジャッジ時間 10,923 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
10,792 KB
testcase_01 AC 41 ms
10,684 KB
testcase_02 AC 39 ms
10,932 KB
testcase_03 AC 39 ms
10,832 KB
testcase_04 AC 39 ms
10,836 KB
testcase_05 AC 39 ms
10,832 KB
testcase_06 AC 40 ms
10,732 KB
testcase_07 AC 39 ms
10,852 KB
testcase_08 AC 39 ms
10,736 KB
testcase_09 AC 39 ms
10,584 KB
testcase_10 AC 41 ms
10,776 KB
testcase_11 AC 39 ms
10,584 KB
testcase_12 AC 39 ms
10,756 KB
testcase_13 AC 40 ms
10,588 KB
testcase_14 AC 38 ms
10,852 KB
testcase_15 AC 40 ms
10,616 KB
testcase_16 AC 813 ms
10,684 KB
testcase_17 AC 781 ms
10,836 KB
testcase_18 AC 778 ms
10,800 KB
testcase_19 AC 808 ms
10,792 KB
testcase_20 AC 823 ms
10,772 KB
testcase_21 AC 39 ms
10,912 KB
testcase_22 AC 39 ms
10,760 KB
testcase_23 AC 255 ms
10,776 KB
testcase_24 AC 157 ms
10,588 KB
testcase_25 AC 714 ms
10,752 KB
testcase_26 AC 453 ms
10,832 KB
testcase_27 AC 706 ms
10,668 KB
testcase_28 AC 335 ms
10,760 KB
testcase_29 AC 470 ms
10,608 KB
testcase_30 AC 224 ms
10,836 KB
testcase_31 AC 126 ms
10,596 KB
testcase_32 AC 612 ms
10,988 KB
testcase_33 AC 132 ms
10,832 KB
testcase_34 AC 42 ms
10,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;

const int mod = 1e9 + 7;

struct ModInt {
	int n,mod;
	vector<int> f;
	vector<int> invf;
	ModInt(int n,int mod):n(n),mod(mod){
		f.resize(n+1);
		invf.resize(n+1);
		preWork(n);
	}
	void preWork(int n){
		f[0] = 1;
		for(int i = 1; i <= n; i++) f[i] = f[i-1]*1ll*i%mod;
		invf[n] = power(f[n],mod-2);
		for(int i = n-1; i >= 0; i--) invf[i] = invf[i+1]*1ll*(i+1)%mod;
	}
	int power(int a,int b){
		int res = 1;
		while(b){
			if(b&1) res = res*1ll*a%mod;
			a = a*1ll*a%mod;
			b /= 2;
		}
		return res;
	}
	int comb(int n,int m){
		return f[n]*1ll*invf[m]%mod*invf[n-m]%mod;
	}
};

auto md = ModInt(1000000, mod);

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	int ans = 0;
	for (int i = 0; i <= m; i++) {
		int x = md.comb(m, i);
		int y = md.power(2, m - i) - 1;
		if (y < 0) y += mod;
		int way = x * 1ll * md.power(y, n) % mod;
		if (i % 2) way = way * 1ll * (mod - 1) % mod;
		ans += way;
		// printf("i = %d: %d\n", i, way);
		if (ans >= mod) ans -= mod;
	}
	printf("%d\n", ans);
	return 0;	
}
0