結果

問題 No.462 6日知らずのコンピュータ
ユーザー hotpepsihotpepsi
提出日時 2016-12-21 00:59:05
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,741 bytes
コンパイル時間 650 ms
コンパイル使用メモリ 61,500 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-14 12:04:20
合計ジャッジ時間 2,732 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 54 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;
typedef long long LL;
#define MOD 1000000007LL

static inline int popcount_ll(LL b) {
#ifdef __GNUC__
	return __builtin_popcountll(b);
#elif _MSC_VER >= 1400
	return (int)__popcnt64(b);
#else
	b = (b & 0x5555555555555555LL) + (b >> 1 & 0x5555555555555555LL);
	b = (b & 0x3333333333333333LL) + (b >> 2 & 0x3333333333333333LL);
	b = (b & 0x0f0f0f0f0f0f0f0fLL) + (b >> 4 & 0x0f0f0f0f0f0f0f0fLL);
	b += b >> 8;
	b += b >> 16;
	return (int)((b + (b >> 32)) & 0x7F);
#endif
}

struct modll {
	long long x;
	modll() { }
	modll(long long _x) : x(_x) { }
	operator int() const { return (int)x; }
	modll operator+(const modll &r) { return (x + r.x) % MOD; }
	modll operator+=(const modll &r) { return x = (x + r.x) % MOD; }
	modll operator-(const modll &r) { return (x + MOD - r.x) % MOD; }
	modll operator-=(const modll &r) { return x = (x + MOD - r.x) % MOD; }
	modll operator*(const modll &r) { return (x * r.x) % MOD; }
	modll operator*(int r) { return (x * r) % MOD; }
	modll operator*=(const modll &r) { return x = (x * r.x) % MOD; }
	static modll modinv(int a) { return modpow(a, MOD - 2); }
	static modll modpow(int a, int b) {
		modll x = a, r = 1;
		for (; b; b >>= 1, x *= x) if (b & 1) r *= x;
		return r;
	}
};

int main(int argc, char *argv[]) {
	int N, k;
	cin >> N >> k;
	LL prev = 0;
	modll ans = 1;
	for (int i = 0; i < k; ++i) {
		LL a;
		cin >> a;
		if ((a & prev) != prev) {
			ans = 0;
		}
		int inc = popcount_ll(prev ^ a);
		for (int j = 2; j <= inc; ++j) {
			ans *= j;
		}
		prev = a;
	}
	int inc = N - popcount_ll(prev);
	for (int j = 2; j <= inc; ++j) {
		ans *= j;
	}
	cout << ans << endl;
	return 0;
}
0