結果
| 問題 |
No.462 6日知らずのコンピュータ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-03 12:14:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,453 bytes |
| コンパイル時間 | 1,900 ms |
| コンパイル使用メモリ | 164,236 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-28 08:52:20 |
| 合計ジャッジ時間 | 3,907 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 WA * 52 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7
int binally_count(ll n){
string str(std::bitset<62>(n).to_string<char, std::char_traits<char>, std::allocator<char> >());
int cnt=0;
REP(i,62){
if(str[i]=='1')cnt++;
}
return cnt;
}
ll nPn(int n){
ll sum=1;
rep(i,1,n+1){
sum*=i;
sum%=mod;
}
return sum;
}
ll bainary(ll x){
ll y,i,ans;
ans=0;
i=0;
while (x>0)
{
y=x%2;
ans=ans+y*pow(10,i);
x=x/2;
i+=1;
}
return ans;
}
bool check(ll a,ll b){
string ab=to_string(bainary(a));
string bb=to_string(bainary(b));
while(ab.size()!=bb.size()){bb="0"+bb;}
REP(i,ab.size()){
if(ab[i]=='0'&&bb[i]=='1'){
return false;
}
}
return true;
}
int main(){
int n,k;
cin>>n>>k;
ll a[61];
REP(i,n)cin>>a[i];
ll ans=0;
if(k==0){
ans=nPn(n);
print(ans);
return 0;
}
sort(a,a+k);
rep(i,1,k){
if(check(a[i],a[i-1])==false){
print(0);
return 0;
}
}
int pre_cnt=binally_count(a[0]);
ans=nPn(pre_cnt);
rep(i,1,k){
int cnt=binally_count(a[i]);
ans=(ans*(nPn(cnt-pre_cnt))%mod)%mod;
pre_cnt=cnt;
}
print(ans);
}