結果

問題 No.1846 Good Binary Matrix
コンテスト
ユーザー 👑 potato167
提出日時 2021-12-07 08:58:33
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 965 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 128 ms
コンパイル使用メモリ 85,632 KB
実行使用メモリ 86,792 KB
最終ジャッジ日時 2026-03-29 00:28:36
合計ジャッジ時間 4,344 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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)
0