結果
問題 |
No.462 6日知らずのコンピュータ
|
ユーザー |
![]() |
提出日時 | 2017-10-17 18:24:15 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 695 bytes |
コンパイル時間 | 1,517 ms |
コンパイル使用メモリ | 160,460 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-17 22:28:59 |
合計ジャッジ時間 | 3,552 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 84 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i, n) for(int i = 0; i < (n); i++) #define MEM(a, x) memset(a, x, sizeof(a)) #define ALL(a) a.begin(), a.end() #define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) typedef long long ll; typedef pair<int, int> P; int n, k; ll a[100], MOD = 1000000007; int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin >> n >> k; FOR(i, k) cin >> a[i]; a[k] = 0; a[k+1] = (1LL<<n)-1; k += 2; sort(a, a+k); ll ret = 1; FOR(i, k-1) { if (a[i] & ~a[i+1]) ret = 0; int x = __builtin_popcountll(a[i+1])-__builtin_popcountll(a[i]); while (x > 1) { ret = ret * (x--) % MOD; } } cout << ret << endl; return 0; }