結果

問題 No.462 6日知らずのコンピュータ
ユーザー Akijin_007
提出日時 2023-09-01 13:22:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 702 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 52,480 KB
最終ジャッジ日時 2025-01-03 06:31:58
合計ジャッジ時間 6,925 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

#int(input())
#map(int, input().split())
#list(map(int, input().split()))

N, k = map(int, input().split())
a = []
if k != 0:
    a = list(map(int, input().split()))
mod = 10 ** 9 + 7

m = 100
fac = [1] * (m + 1)
for i in range(1, m+1):
    fac[i] = (fac[i-1] * i) % mod

a = sorted(a)
if 0 not in a:
    a = [0] + a
if 2**N - 1 not in a:
    a.append(2**N-1)

f = 1
for i in range(len(a)-1):
    u = a[i] ^ a[i+1]
    if u + a[i] != a[i+1]:
        f = 0
        break

if f == 0:
    print(0)
    exit()

def popcount(a):
    b = format(a, "b")
    return b.count("1")

ans = 1
for i in range(len(a)-1):
    d = popcount(a[i+1]) - popcount(a[i])
    ans = (ans * fac[d]) % mod

print(ans)











0