結果

問題 No.462 6日知らずのコンピュータ
ユーザー rlangevin
提出日時 2023-03-02 08:59:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,788 KB
実行使用メモリ 57,120 KB
最終ジャッジ日時 2024-09-17 05:49:37
合計ジャッジ時間 5,183 ms
ジャッジサーバーID
(参考情報)
judge6 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

def popcount(n):
    cnt = 0
    while n:
        cnt += n & 1
        n >>= 1
    return cnt

N, K = map(int, input().split())
if K:
    A = list(map(int, input().split()))
else:
    A = []
mod = 10 ** 9 + 7
A.append((1 << N) - 1)
A.append(0)
A.sort()

M = 65
fact = [1] * M
for i in range(1, M):
    fact[i] = fact[i - 1] * i
    fact[i] %= mod

ans = 1
for i in range(K + 1):
    if A[i] | A[i + 1] != A[i + 1]:
        print(0)
        exit()
    ans *= fact[popcount(A[i] ^ A[i + 1])]
    ans %= mod

print(ans)
0