結果

問題 No.462 6日知らずのコンピュータ
ユーザー char134217728
提出日時 2017-08-20 01:20:45
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 853 bytes
コンパイル時間 1,390 ms
コンパイル使用メモリ 163,688 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-14 16:31:25
合計ジャッジ時間 3,729 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 84
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:24:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   24 | main(){
      | ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

ll f[65];
vector<ll> a;
int bc(ll i){
  int co = 0;
  while(i > 0){
    if(i&1)co++;
    i >>= 1;
  }
  return co;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  f[0] = 1;
  FOR(i, 1, 65) f[i] = f[i-1] * i % mod;
  int n, k;
  cin >> n >> k;
  a.pb(0);
  FOR(i, 0, k){
    ll b;
    cin >> b;
    a.pb(b);
  }
  a.pb((1ll << n) - 1);
  sort(a.begin(), a.end());
  ll ans = 1;
  FOR(i, 1, a.size()){
    if((a[i] & a[i-1]) != a[i-1]){
      ans = 0;
      break;
    }
    ans = ans * f[bc(a[i]) - bc(a[i-1])] % mod;
  }
  cout << ans << endl;
}
0