結果
問題 |
No.462 6日知らずのコンピュータ
|
ユーザー |
|
提出日時 | 2017-07-31 16:40:41 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,296 bytes |
コンパイル時間 | 1,642 ms |
コンパイル使用メモリ | 83,340 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-11 00:09:48 |
合計ジャッジ時間 | 4,136 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 43 WA * 41 |
ソースコード
#include<cstdio> #include<iostream> #include<algorithm> #include<string> #include<queue> #include<vector> #include<functional> #include<cmath> #include<map> #include<stack> #include<set> #include<numeric> #include<limits> #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<ll, string> pls; ll mod = ll(1e9 + 7); ll fuc(int n) { ll res = 1; for (int i = 1; i <= n; i++) { res *= i; res %= mod; } return res; } int numofbits(int bits) { int num; num = (bits >> 1) & 03333333333; num = bits - num - ((num >> 1) & 03333333333); num = ((num + (num >> 3)) & 0707070707) % 077; return num; } int main() { int n, k; int a[100] = {0}; ll ans; cin >> n >> k; for (int i = 0; i < k; i++) { cin >> a[i]; } sort(a, a + k); for (int i = 0; i < k-1; i++) { if ((a[i + 1] | a[i]) != a[i + 1]) { cout << 0 << endl; return 0; } } if (k == 0) { ans = fuc(n); cout << ans << endl; return 0; } ans = numofbits(a[0]); for (int i = 1; i < k; i++) { ans *= fuc(numofbits(a[i]) - numofbits(a[i - 1])); ans %= mod; } ans *= fuc(numofbits(pow(2, n) - 1) - numofbits(a[k - 1])); ans %= mod; cout << ans << endl; return 0; }