結果
問題 |
No.462 6日知らずのコンピュータ
|
ユーザー |
![]() |
提出日時 | 2018-04-06 19:12:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,146 bytes |
コンパイル時間 | 680 ms |
コンパイル使用メモリ | 66,156 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 10:49:14 |
合計ジャッジ時間 | 2,761 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 69 WA * 15 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int MOD = 1e9+7; int f[100]; int fract(int n){ if(n == 0 || n==1) return f[n] = 1; if(f[n] != 0) return f[n]%MOD; return f[n] = n*fract(n-1)%MOD; } unsigned long long bit_count(unsigned long long N){ unsigned long long cnt = 0; while(N){ cnt++; N &= N-1; } return cnt; } bool comp(unsigned long long a, unsigned long long b){ return bit_count(a) < bit_count(b); } int main(){ int N,k; cin >> N >> k; fract(N); if(k==0){ cout << fract(N)%MOD << endl; return 0; } vector<unsigned long long> A(k+2); for(int i=1;i<=k;i++){ cin >> A[i]; } A[0] = 0; A[k+1] = ((unsigned long long)1<<N)-1; sort(A.begin(), A.end(), comp); long long ans = 1ll; for(int i=0;i<A.size()-1;i++){ if(bit_count(A[i+1]) < bit_count(A[i+1] | A[i]) ){ cout << 0 << endl; return 0; } unsigned long long diff = bit_count(A[i] ^ A[i+1]); (ans *= fract(diff) ) %= MOD; } cout << ans << endl; return 0; }