結果

問題 No.462 6日知らずのコンピュータ
ユーザー SSRS
提出日時 2020-11-12 15:13:21
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 1,428 ms
コンパイル使用メモリ 74,752 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-22 19:11:11
合計ジャッジ時間 3,256 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
const long long MOD = 1000000007;
long long fact(int n){
	long long ans = 1;
	for (int i = 1; i <= n; i++){
		ans = ans * i % MOD;
	}
	return ans;
}
int main(){
	int N, k;
	cin >> N >> k;
	vector<long long> a(k + 2);
	a[0] = 0;
	a[k + 1] = ((long long) 1 << N) - 1;
	for (int i = 1; i <= k; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	long long ans = 1;
	for (int i = 0; i <= k; i++){
		if ((a[i] & a[i + 1]) != a[i]){
			cout << 0 << endl;
			return 0;
		}
		ans = ans * fact(__builtin_popcountll(a[i + 1] & ~a[i])) % MOD;
	}
	cout << ans << endl;
}
0