結果

問題 No.462 6日知らずのコンピュータ
ユーザー ferinferin
提出日時 2017-01-26 18:13:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,113 bytes
コンパイル時間 1,503 ms
コンパイル使用メモリ 168,628 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-25 00:03:57
合計ジャッジ時間 4,323 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 1 ms
4,376 KB
testcase_53 AC 1 ms
4,376 KB
testcase_54 WA -
testcase_55 AC 1 ms
4,380 KB
testcase_56 AC 1 ms
4,380 KB
testcase_57 WA -
testcase_58 AC 1 ms
4,376 KB
testcase_59 AC 1 ms
4,376 KB
testcase_60 WA -
testcase_61 AC 2 ms
4,376 KB
testcase_62 WA -
testcase_63 AC 2 ms
4,376 KB
testcase_64 WA -
testcase_65 WA -
testcase_66 AC 1 ms
4,380 KB
testcase_67 AC 1 ms
4,380 KB
testcase_68 WA -
testcase_69 AC 1 ms
4,380 KB
testcase_70 AC 1 ms
4,380 KB
testcase_71 AC 2 ms
4,380 KB
testcase_72 WA -
testcase_73 AC 1 ms
4,380 KB
testcase_74 WA -
testcase_75 AC 1 ms
4,376 KB
testcase_76 WA -
testcase_77 WA -
testcase_78 AC 1 ms
4,380 KB
testcase_79 AC 1 ms
4,380 KB
testcase_80 AC 2 ms
4,376 KB
testcase_81 AC 1 ms
4,380 KB
testcase_82 AC 1 ms
4,376 KB
testcase_83 AC 1 ms
4,376 KB
testcase_84 WA -
testcase_85 WA -
testcase_86 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

ll fact[70];

int main(void)
{
  int n, k;
  cin >> n >> k;
  ll a[70];
  REP(i, k) cin >> a[i];

  sort(a, a+n);
  bool isbit[70] = {false};
  REP(i, k) {
    //a_iの立っているビットをチェク
    REP(j, n) {
      if(isbit[j] && !(a[i] >> j & 1)) {cout << 0 << endl; return 0;}
      if(!isbit[j] && a[i] >> j & 1) isbit[j] = true;
    }
  }

  fact[0] = 1;
  FOR(i, 1, 70) {
    fact[i] = (fact[i-1] * i) % MOD;
  }

  int count = 0;
  ll ans = 1;
  REP(i, k) {
    int diff = __builtin_popcount(a[i]) - count;
    count = __builtin_popcount(a[i]);
    ans = (ans * fact[diff]) % MOD;
  }
  if(n - count > 0) {
    ans = (ans * fact[n-count]) % MOD;
  }

  cout << ans << endl;

  return 0;
}
0