結果
| 問題 |
No.462 6日知らずのコンピュータ
|
| コンテスト | |
| ユーザー |
eve__fuyuki
|
| 提出日時 | 2018-03-16 05:10:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 992 bytes |
| コンパイル時間 | 652 ms |
| コンパイル使用メモリ | 66,412 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-21 14:08:55 |
| 合計ジャッジ時間 | 2,667 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 WA * 47 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
const long long mod = 10e9+7;
long long factorial[61];
int N;
int diff(long long x,long long y){
int count = 0;
for(int i=0;i<N;i++){
if((x & 1<<i) > (y & 1 << i)){
return 0;
}
else if((x & 1<<i) < (y & 1 << i)){
count++;
}
}
return count;
}
int main(){
int k,d;
vector<long long> a;
long long input;
long long ans = 1;
cin >> N >> k;
factorial[0] = 1;
for(int i=1;i<=N;i++){
factorial[i] = factorial[i-1]*i % mod;
}
for(int i=0;i<k;i++){
cin >> input;
a.push_back(input);
}
a.push_back(0);
sort(a.begin(),a.end());
a.push_back((1<<N) -1);
for(int i=0;i<a.size()-1;i++){
d = diff(a[i],a[i+1]);
if(d == 0){
ans = 0;
break;
}
ans = (ans*factorial[d])%mod;
}
cout << ans << endl;
return 0;
}
eve__fuyuki