結果
| 問題 |
No.1846 Good Binary Matrix
|
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2023-02-05 17:30:09 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,043 ms / 2,000 ms |
| コード長 | 565 bytes |
| コンパイル時間 | 157 ms |
| コンパイル使用メモリ | 82,852 KB |
| 実行使用メモリ | 92,884 KB |
| 最終ジャッジ日時 | 2024-07-04 05:34:37 |
| 合計ジャッジ時間 | 13,085 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
ソースコード
H, W = map(int, input().split())
mod = 10 ** 9 + 7
n = 1010101
fact = [1] * (n + 1)
invfact = [1] * (n + 1)
for i in range(1, n):
fact[i + 1] = ((i+1) * fact[i]) % mod
invfact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
invfact[i] = invfact[i + 1] * (i + 1) % mod
def comb(n, r):
if n < 0 or r < 0 or n - r < 0:
return 0
return fact[n] * invfact[r] * invfact[n - r] % mod
ans = 0
pm = 1
for i in range(W, -1, -1):
ans += pow(pow(2, i, mod) - 1, H, mod) * pm * comb(W, i)
ans %= mod
pm *= -1
print(ans)
rlangevin