結果

問題 No.1846 Good Binary Matrix
ユーザー square1001square1001
提出日時 2022-02-18 21:55:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 548 bytes
コンパイル時間 568 ms
コンパイル使用メモリ 10,640 KB
実行使用メモリ 814,156 KB
最終ジャッジ日時 2023-09-11 19:03:29
合計ジャッジ時間 3,308 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,688 KB
testcase_01 AC 16 ms
7,840 KB
testcase_02 AC 16 ms
7,840 KB
testcase_03 AC 15 ms
7,836 KB
testcase_04 AC 16 ms
7,688 KB
testcase_05 AC 16 ms
7,724 KB
testcase_06 AC 16 ms
7,732 KB
testcase_07 AC 16 ms
7,652 KB
testcase_08 AC 16 ms
7,808 KB
testcase_09 AC 16 ms
7,700 KB
testcase_10 AC 16 ms
7,688 KB
testcase_11 AC 16 ms
7,736 KB
testcase_12 AC 16 ms
7,648 KB
testcase_13 AC 15 ms
7,744 KB
testcase_14 AC 16 ms
7,728 KB
testcase_15 AC 16 ms
7,732 KB
testcase_16 MLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 1000000007

H, W = map(int, input().split())

fact = [ 0 ] * (H + 1)
fact[0] = 1
for i in range(H):
	fact[i + 1] = fact[i] * (i + 1)
factinv = [ 0 ] * (H + 1)
factinv[H] = pow(fact[H], MOD - 2, MOD)
for i in range(H - 1, -1, -1):
	factinv[i] = factinv[i + 1] * (i + 1)

answer = 0
power2 = 1
for i in range(H, -1, -1):
	subanswer = pow(MOD - power2 + 1, W, MOD)
	comb = fact[H] * factinv[i] * factinv[H - i]
	if (i + W) % 2 == 0:
		answer += comb * subanswer
	else:
		answer -= comb * subanswer
	power2 = power2 * 2 % MOD

print(answer % MOD)
0