結果
| 問題 | No.462 6日知らずのコンピュータ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-26 14:21:05 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| + 379µs | |
| コード長 | 861 bytes |
| 記録 | |
| コンパイル時間 | 1,159 ms |
| コンパイル使用メモリ | 173,348 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-26 14:21:27 |
| 合計ジャッジ時間 | 4,240 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 84 |
ソースコード
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long LL;
const int N = 70, MOD = 1000000007;
LL a[N];
bool ok;
int n, k, pw[N], ans;
int main() {
// freopen("computer.in", "r", stdin);
// freopen("computer.out", "w", stdout);
scanf("%d%d", &n, &k);
for (int i = 1; i <= k; ++i) scanf("%lld", &a[i]);
sort(a + 1, a + k + 1);
pw[0] = 1;
for (int i = 1; i <= n; ++i) pw[i] = 1LL * pw[i - 1] * i % MOD;
a[0] = 0LL, a[k + 1] = (1LL << n) - 1;
ans = 1, ok = true;
for (int i = 1; i <= k + 1; ++i) {
if ((a[i - 1] & a[i]) != a[i - 1]) {
ok = false;
break;
}
int cnt = __builtin_popcountll(a[i]) - __builtin_popcountll(a[i - 1]);
ans = 1LL * ans * pw[cnt] % MOD;
}
printf("%d\n", ok ? ans : 0);
return 0;
}