結果

問題 No.462 6日知らずのコンピュータ
ユーザー qwegat
提出日時 2023-01-05 13:13:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 82,156 KB
実行使用メモリ 59,724 KB
最終ジャッジ日時 2024-11-29 02:45:14
合計ジャッジ時間 5,268 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n,k = list(map(int,input().split()))
na = []
ns = 0
nd = 1
df = False
if k > 0:
	a = list(map(int,input().split()))
	a.append(0)
	
	a.sort()

	for i in range(k):
		if (a[i])&(~a[i+1]) > 0:
			df = True
			break
		else:
			d = bin(a[i]^a[i+1]).count("1")
			na.append(d)
			ns += d
			nd *= math.factorial(d)
if df:
	print(0)
elif ns > n:
	print(0)
else:
	nd *= math.factorial(n-ns)
	print(nd%1000000007)
0