結果
問題 |
No.462 6日知らずのコンピュータ
|
ユーザー |
|
提出日時 | 2016-12-13 02:12:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 951 bytes |
コンパイル時間 | 1,715 ms |
コンパイル使用メモリ | 171,416 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 00:24:14 |
合計ジャッジ時間 | 3,737 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 55 WA * 29 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr) #define all(x) (x).begin(),(x).end() #define pb push_back #define fi first #define se second const ll mod=1e9+7; inline ll fact(int n) { ll ret=1; for(int i=2; i<=n; ++i) (ret*=i)%=mod; return ret; } ll solve() { int n,k; scanf(" %d %d", &n, &k); int ct[61]={}; vector<int> x; rep(i,k) { ll a; scanf(" %lld", &a); int bit = __builtin_popcount(a); x.pb(bit); ++ct[bit]; } if(k==0) return fact(n); rep(i,61) if(ct[i]>1) return 0; sort(all(x)); ll ret=1; (ret*=fact(x[0]))%=mod; for(int i=1; i<k; ++i) (ret*=fact(x[i]-x[i-1]))%=mod; (ret*=fact(n-x[k-1]))%=mod; return ret; } int main() { cout << solve() << endl; return 0; }