結果

問題 No.462 6日知らずのコンピュータ
ユーザー betit0919
提出日時 2019-07-07 20:45:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 968 bytes
コンパイル時間 1,030 ms
コンパイル使用メモリ 109,980 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-05 09:47:44
合計ジャッジ時間 3,102 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 84
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,k;
  ll fac[100];
  fac[0]=fac[1]=1ll;
  for (int i=2;i<100;i++){
    fac[i]=fac[i-1]*i%MOD;
  }
  cin>>N>>k;
  vector<ll>a(k);
  for(int i=0;i<k;i++)cin>>a[i];
  a.push_back(0);a.push_back((1ll<<N)-1);
  sort(ALL(a));
  a.erase(unique(ALL(a)),a.end());
  ll ans=1ll;
  for(int i=0;i<a.size()-1;i++){
    if((a[i+1]&a[i])==a[i]){
      ans*=fac[__builtin_popcountll(a[i+1]-a[i])];
      ans%=MOD;
    }else{
      ans*=0;
    }
  }
  cout<<ans<<endl;
}
0