結果

問題 No.462 6日知らずのコンピュータ
ユーザー masa
提出日時 2017-02-15 12:27:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 831 bytes
コンパイル時間 1,069 ms
コンパイル使用メモリ 77,188 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-29 22:55:36
合計ジャッジ時間 2,992 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int mod = 1e9 + 7;

vector<long long> make_fact(int n_max = 60) {
	vector<long long> fact(n_max + 1, 1LL);
	for (int i = 2; i <= n_max; i++) {
		fact[i] = fact[i - 1] * i % mod;
	}
	return fact;
}

int main() {
	int n, k;
	cin >> n >> k;

	vector<long long> a(k, 0);
	for (int i = 0; i < k; i++) {
		cin >> a[i];
	}
	a.emplace_back(0);
	a.emplace_back((1LL << n) - 1);
	sort(a.begin(), a.end());

	auto fact = make_fact();

	long long ret = 1;
	for (int i = 1; i < a.size(); i++) {
		if ((a[i] | a[i - 1]) != a[i]) {
			ret = 0;
			break;
		}

		int diff = __builtin_popcountll(a[i]) - __builtin_popcountll(a[i - 1]);
		printf("%10lld %d\n", a[i], diff);
		ret = ret * fact[diff] % mod;
	}
	cout << ret << endl;
	return 0;
}
0