結果
| 問題 |
No.1846 Good Binary Matrix
|
| コンテスト | |
| ユーザー |
👑 potato167
|
| 提出日時 | 2021-12-07 08:58:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 666 ms / 2,000 ms |
| コード長 | 965 bytes |
| コンパイル時間 | 160 ms |
| コンパイル使用メモリ | 82,096 KB |
| 実行使用メモリ | 84,864 KB |
| 最終ジャッジ日時 | 2024-07-07 10:20:01 |
| 合計ジャッジ時間 | 8,816 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
ソースコード
class combi:
def __init__(self,max_n,mod):
max_n+=1
self.mod=mod
self.fact=[0]*max_n
self.rev=[0]*max_n
self.fact_rev=[0]*max_n
self.fact[0]=1
self.rev[0]=1
self.fact_rev[0]=1
for i in range(max_n):
if i<=1:
self.fact[i]=1
self.rev[i]=1
self.fact_rev[i]=1
continue
self.fact[i]=(i*self.fact[i-1])%mod
self.rev[i]=mod-((mod//i)*self.rev[mod%i])%mod
self.fact_rev[i]=(self.fact_rev[i-1]*self.rev[i])%mod
def combination(self,a,b):
if a<b:
return 0
ans=(self.fact_rev[a-b]*self.fact_rev[b])%self.mod
return (ans*self.fact[a])%self.mod
M=10**9+7
H,W=map(int,input().split())
table=combi(W+1,M)
tmp=1
sign=pow(-1,H+W)
ans=0
for i in range(W+1):
ans+=(table.combination(W,i)*sign*pow(1-tmp,H,M))%M
sign*=-1
tmp=(tmp*2)%M
ans%=M
print(ans)
potato167