結果
問題 | No.462 6日知らずのコンピュータ |
ユーザー |
![]() |
提出日時 | 2017-01-26 20:36:54 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,177 bytes |
コンパイル時間 | 1,330 ms |
コンパイル使用メモリ | 162,516 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-23 11:44:00 |
合計ジャッジ時間 | 3,109 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 84 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<ll> VL; typedef vector<VL> VVL; typedef pair<int, int> PII; #define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i) #define REP(i, n) FOR(i, 0, n) #define ALL(x) x.begin(), x.end() #define MOD 1000000007 #define INF 1000000000 #define PI 3.14159265359 #define EPS 1e-12 ll fact[70]; int main(void) { int n, k; cin >> n >> k; ll a[70]; REP(i, k) cin >> a[i]; sort(a, a+k); ll before = 0; REP(i, k) { if((a[i] & before) != before) {cout << "0" << endl; return 0;} before = a[i]; } fact[0] = 1; FOR(i, 1, 70) { fact[i] = (fact[i-1] * i) % MOD; //cout << fact[i] << " "; } int count = 0; ll ans = 1; before = 0; REP(i, k) { count = __builtin_popcountll(before ^ a[i]); ans = (ans * fact[count]) % MOD; before = a[i]; //cout << a[i] << " " << ans << " " << count << " " << fact[count] << endl; } count = n - __builtin_popcountll(before); //cout << ans << " " << count << " " << fact[count] << endl; ans = (ans * fact[count]) % MOD; cout << ans << endl; return 0; }