結果
問題 |
No.462 6日知らずのコンピュータ
|
ユーザー |
|
提出日時 | 2021-02-05 13:21:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 733 bytes |
コンパイル時間 | 1,979 ms |
コンパイル使用メモリ | 198,328 KB |
最終ジャッジ日時 | 2025-01-18 11:44:14 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 84 |
ソースコード
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long solve(int n, const vector<long long> &a) { vector<long long> f(n+1); f[0] = 1; for (int i = 1; i <= n; i++) f[i] = i * f[i-1] % MOD; long long x = 0; long long ret = 1; for (int i = 0; i < a.size(); i++) { if ((a[i] & x) != x) return 0; int l = __builtin_popcountll(a[i] & ~x); ret = ret * f[l] % MOD; x = a[i]; } return ret; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; vector<long long> a(k); for (int i = 0; i < k; i++) cin >> a[i]; sort(a.begin(), a.end()); a.push_back((1LL<<n) - 1); cout << solve(n, a) << endl; return 0; }