結果
| 問題 |
No.1846 Good Binary Matrix
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-18 23:21:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 886 ms / 2,000 ms |
| コード長 | 516 bytes |
| コンパイル時間 | 160 ms |
| コンパイル使用メモリ | 82,464 KB |
| 実行使用メモリ | 77,696 KB |
| 最終ジャッジ日時 | 2024-06-29 09:53:21 |
| 合計ジャッジ時間 | 10,710 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
ソースコード
H,W = map(int,input().split())
P = 10 ** 9 + 7
C = W + 5
fact = [1] * C
fact_inv = [1] * C
for i in range(2,C):
fact[i] = fact[i-1] * i % P
fact_inv[-1] = pow(fact[-1],P-2,P)
for i in range(C-2,0,-1):
fact_inv[i] = fact_inv[i+1] * (i + 1) % P
def comb(n,k):
return fact[n] * fact_inv[k] % P * fact_inv[n-k] % P
ans = 0
for j in range(W+1):
if j % 2 == 0:
c = 1
else:
c = -1
tmp = comb(W,j)
t = pow(2,W-j,P)-1
s = pow(t,H,P)
ans = (ans + c * tmp*s) % P
print(ans)