結果

問題 No.1846 Good Binary Matrix
ユーザー publfl2publfl2
提出日時 2022-02-18 22:26:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 497 ms / 2,000 ms
コード長 809 bytes
コンパイル時間 238 ms
コンパイル使用メモリ 32,984 KB
実行使用メモリ 10,876 KB
最終ジャッジ日時 2023-09-11 19:32:06
合計ジャッジ時間 7,334 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
10,800 KB
testcase_01 AC 10 ms
10,792 KB
testcase_02 AC 10 ms
10,812 KB
testcase_03 AC 10 ms
10,800 KB
testcase_04 AC 10 ms
10,732 KB
testcase_05 AC 10 ms
10,800 KB
testcase_06 AC 10 ms
10,828 KB
testcase_07 AC 10 ms
10,816 KB
testcase_08 AC 11 ms
10,672 KB
testcase_09 AC 10 ms
10,820 KB
testcase_10 AC 10 ms
10,796 KB
testcase_11 AC 11 ms
10,872 KB
testcase_12 AC 11 ms
10,820 KB
testcase_13 AC 10 ms
10,792 KB
testcase_14 AC 10 ms
10,876 KB
testcase_15 AC 10 ms
10,668 KB
testcase_16 AC 497 ms
10,816 KB
testcase_17 AC 496 ms
10,796 KB
testcase_18 AC 480 ms
10,800 KB
testcase_19 AC 465 ms
10,792 KB
testcase_20 AC 495 ms
10,732 KB
testcase_21 AC 209 ms
10,800 KB
testcase_22 AC 219 ms
10,828 KB
testcase_23 AC 11 ms
10,728 KB
testcase_24 AC 10 ms
10,736 KB
testcase_25 AC 359 ms
10,788 KB
testcase_26 AC 235 ms
10,816 KB
testcase_27 AC 22 ms
10,792 KB
testcase_28 AC 59 ms
10,736 KB
testcase_29 AC 158 ms
10,792 KB
testcase_30 AC 396 ms
10,796 KB
testcase_31 AC 356 ms
10,736 KB
testcase_32 AC 409 ms
10,796 KB
testcase_33 AC 470 ms
10,820 KB
testcase_34 AC 11 ms
10,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#define MOD 1000000007

long long int power(long long int a, long long int b)
{
	long long int ans = 1;
	long long int k = a;
	while(b)
	{
		if(b%2==1) ans*=k, ans%=MOD;
		k*=k, k%=MOD;
		b/=2;
	}
	return ans;
}
long long int inv(long long int k)
{
	return power(k,MOD-2);
}

long long int fact[1000010];
long long int comb(int a, int b)
{
	long long int ans = fact[a];
	ans *= inv(fact[b]), ans %= MOD;
	ans *= inv(fact[a-b]), ans %= MOD;
	return ans;
}

int main()
{
	fact[0] = 1;
	for(int i=1;i<=1000000;i++) fact[i] = (i*fact[i-1])%MOD;
	
	int a,b;
	scanf("%d%d",&a,&b);
	
	long long int ans = 0;
	for(int i=0;i<=a;i++)
	{
		long long int t = power(2,a-i)-1;
		t = power(t,b);
		t*=comb(a,i), t %= MOD;
		if(i%2==0) ans+=t;
		else ans += (MOD-t);
		ans %= MOD;
	}
	printf("%lld",ans);
}
0