結果
問題 | No.462 6日知らずのコンピュータ |
ユーザー | hirokazu1020 |
提出日時 | 2016-12-13 00:28:11 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,676 bytes |
コンパイル時間 | 1,292 ms |
コンパイル使用メモリ | 96,824 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-29 18:55:09 |
合計ジャッジ時間 | 3,373 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 84 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include<sstream> #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<climits> #include<cmath> #include<string> #include<vector> #include<set> #include<map> #include<queue> #include<numeric> #include<functional> #include<algorithm> #include<bitset> #include<tuple> #include<unordered_set> #include<unordered_map> #include<random> using namespace std; #define INF (1<<29) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() #define uniq(v) v.erase(unique(all(v)),v.end()) #define MOD 1000000007 inline int popcount64(unsigned long long x) { #if defined(_MSC_VER) return __popcnt(x >> 32) + __popcnt(x); #elif defined(__GNUC__) return __builtin_popcountll(x); #else x = (x >> 1 & 0x5555555555555555ULL) + (x & 0x5555555555555555ULL); x = (x >> 2 & 0x3333333333333333ULL) + (x & 0x3333333333333333ULL); x = (x >> 4 & 0x0f0f0f0f0f0f0f0fULL) + (x & 0x0f0f0f0f0f0f0f0fULL); x = (x >> 8 & 0x00ff00ff00ff00ffULL) + (x & 0x00ff00ff00ff00ffULL); x = (x >> 16 & 0x0000ffff0000ffffULL) + (x & 0x0000ffff0000ffffULL); return ((x >> 32) + (x & 0xffffffff)); #endif } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, k; cin >> n >> k; long long prev = 0, prevpop = 0; long long ans = 1; long long a[61]; rep(i, k)cin >> a[i]; sort(a, a + k); rep(i,k) { if ((a[i]&prev)!=prev) { ans = 0; break; } int pop = popcount64(a[i]); for (int i = 1; i <= pop - prevpop;i++) { (ans *= i) %= MOD; } prev = a[i]; prevpop = pop; } if (prevpop != n) { for (int i = 1; i <= n - prevpop; i++) { (ans *= i) %= MOD; } } cout << ans << endl; return 0; }