結果

問題 No.1846 Good Binary Matrix
ユーザー rlangevinrlangevin
提出日時 2023-02-05 17:30:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,074 ms / 2,000 ms
コード長 565 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 95,216 KB
最終ジャッジ日時 2023-09-17 09:03:30
合計ジャッジ時間 15,017 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
91,644 KB
testcase_01 AC 102 ms
91,656 KB
testcase_02 AC 102 ms
91,832 KB
testcase_03 AC 101 ms
91,680 KB
testcase_04 AC 102 ms
91,708 KB
testcase_05 AC 101 ms
91,704 KB
testcase_06 AC 102 ms
91,712 KB
testcase_07 AC 100 ms
91,728 KB
testcase_08 AC 102 ms
91,732 KB
testcase_09 AC 102 ms
91,540 KB
testcase_10 AC 102 ms
91,688 KB
testcase_11 AC 100 ms
91,852 KB
testcase_12 AC 98 ms
91,828 KB
testcase_13 AC 100 ms
91,856 KB
testcase_14 AC 100 ms
91,544 KB
testcase_15 AC 99 ms
91,604 KB
testcase_16 AC 1,045 ms
92,548 KB
testcase_17 AC 1,059 ms
92,728 KB
testcase_18 AC 1,041 ms
92,468 KB
testcase_19 AC 1,074 ms
92,456 KB
testcase_20 AC 1,074 ms
92,464 KB
testcase_21 AC 100 ms
91,784 KB
testcase_22 AC 102 ms
91,764 KB
testcase_23 AC 391 ms
92,116 KB
testcase_24 AC 260 ms
92,396 KB
testcase_25 AC 950 ms
92,460 KB
testcase_26 AC 625 ms
92,424 KB
testcase_27 AC 959 ms
92,564 KB
testcase_28 AC 478 ms
92,512 KB
testcase_29 AC 657 ms
92,556 KB
testcase_30 AC 335 ms
92,500 KB
testcase_31 AC 221 ms
95,092 KB
testcase_32 AC 824 ms
92,468 KB
testcase_33 AC 232 ms
95,216 KB
testcase_34 AC 111 ms
91,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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