結果

問題 No.462 6日知らずのコンピュータ
ユーザー compass19
提出日時 2016-12-13 00:59:44
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 670 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-11-29 23:53:06
合計ジャッジ時間 4,481 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
@lru_cache(maxsize=None)
def power(n):
	if n <= 1: return 1
	else: return power(n-1)*n


n, k = map(int, input().split())
list_of_list = list()
if k != 0:
	a_list = list(map(int, input().split()))
	for m in a_list:
		tmp = list(map(int, bin(m)[-1:1:-1]))
		tmp += [0]*(n-len(tmp))
		list_of_list.append(tmp)
list_of_list = sorted(list_of_list, key=lambda x: x.count(1))
list_of_list.append([1]*n)
num_power = 1
source = [0]*n
for _list in list_of_list:
	count = 0
	for i, j in zip(source, _list):
		if j-i < 0: print(0); exit()
		elif j-i == 1: count += 1
	source = _list
	num_power *= (power(count)%(10**9+7))
print(num_power%(10**9+7))
0