結果

問題 No.462 6日知らずのコンピュータ
ユーザー hirokazu1020
提出日時 2016-12-13 00:24:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,219 bytes
コンパイル時間 954 ms
コンパイル使用メモリ 97,936 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-29 18:53:09
合計ジャッジ時間 2,738 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42 WA * 42
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

#define MOD 1000000007


int popcount32(unsigned int x) {
#if defined(_MSC_VER)
	return __popcnt(x);
#else
	return __builtin_popcount(x);
#endif
}



int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, k;
	cin >> n >> k;
	int prev = 0, prevpop = 0;
	long long ans = 1;
	int a[61];
	rep(i, k)cin >> a[i];
	sort(a, a + k);
	rep(i,k) {
		if ((a[i]&prev)!=prev) {
			ans = 0;
			break;
		}
		int pop = popcount32(a[i]);
		for (int i = 1; i <= pop - prevpop;i++) {
			(ans *= i) %= MOD;
		}
		prev = a[i];
		prevpop = pop;
	}
	if (prevpop != n) {
		for (int i = 1; i <= n - prevpop; i++) {
			(ans *= i) %= MOD;
		}
	}

	cout << ans << endl;


	return 0;
}
0