結果
| 問題 |
No.462 6日知らずのコンピュータ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-13 00:38:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 616 bytes |
| コンパイル時間 | 1,503 ms |
| コンパイル使用メモリ | 171,280 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-29 23:31:25 |
| 合計ジャッジ時間 | 3,469 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 84 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
int n, k;
cin >> n >> k;
vector<int64_t> a(k + 2);
for (int i = 0; i < k; i++) {
cin >> a[i];
}
a.back() = (1LL << n) - 1;
sort(a.begin(), a.end());
int64_t ans = 1;
for (int i = 0; i < a.size() - 1; i++) {
if (a[i] & ~a[i + 1]) {
ans = 0;
}
int cnt = 0;
int64_t d = a[i] ^ a[i + 1];
for (int64_t d = a[i] ^ a[i + 1]; d > 0; d &= d - 1) {
ans *= ++cnt;
ans %= mod;
}
}
cout << ans << endl;
}