結果
問題 | No.462 6日知らずのコンピュータ |
ユーザー |
|
提出日時 | 2017-02-15 12:28:49 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 834 bytes |
コンパイル時間 | 873 ms |
コンパイル使用メモリ | 76,716 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-29 22:55:52 |
合計ジャッジ時間 | 3,252 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 84 |
ソースコード
#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; }