結果

問題 No.937 Ultra Sword
ユーザー risujirohrisujiroh
提出日時 2019-11-29 22:35:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 998 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 174,740 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 02:37:05
合計ジャッジ時間 5,342 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 163 ms
6,944 KB
testcase_06 AC 95 ms
6,944 KB
testcase_07 AC 103 ms
6,940 KB
testcase_08 AC 50 ms
6,948 KB
testcase_09 AC 40 ms
6,940 KB
testcase_10 AC 114 ms
6,944 KB
testcase_11 AC 12 ms
6,940 KB
testcase_12 AC 52 ms
6,944 KB
testcase_13 AC 50 ms
6,940 KB
testcase_14 AC 59 ms
6,940 KB
testcase_15 AC 43 ms
6,940 KB
testcase_16 AC 4 ms
6,944 KB
testcase_17 AC 7 ms
6,940 KB
testcase_18 AC 46 ms
6,940 KB
testcase_19 AC 28 ms
6,944 KB
testcase_20 AC 25 ms
6,944 KB
testcase_21 AC 124 ms
6,940 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 257 ms
6,940 KB
testcase_25 AC 99 ms
6,940 KB
testcase_26 AC 99 ms
6,940 KB
testcase_27 AC 87 ms
6,944 KB
testcase_28 AC 95 ms
6,940 KB
testcase_29 AC 5 ms
6,940 KB
testcase_30 AC 86 ms
6,944 KB
testcase_31 AC 133 ms
6,940 KB
testcase_32 AC 72 ms
6,940 KB
testcase_33 AC 117 ms
6,940 KB
testcase_34 AC 18 ms
6,940 KB
testcase_35 AC 9 ms
6,940 KB
testcase_36 AC 92 ms
6,940 KB
testcase_37 AC 9 ms
6,944 KB
testcase_38 AC 78 ms
6,944 KB
testcase_39 AC 6 ms
6,944 KB
testcase_40 AC 98 ms
6,940 KB
testcase_41 AC 33 ms
6,948 KB
testcase_42 AC 75 ms
6,940 KB
testcase_43 AC 67 ms
6,944 KB
testcase_44 AC 24 ms
6,944 KB
testcase_45 AC 42 ms
6,944 KB
testcase_46 AC 44 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template<class Z> vector<Z> divisor(Z n) {
  vector<Z> res;
  Z i;
  for (i = 1; i * i < n; ++i) if (n % i == 0) res.push_back(i), res.push_back(n / i);
  if (i * i == n) res.push_back(i);
  sort(begin(res), end(res));
  return res;
}

constexpr int sup = 1e5;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), v;
  vector<long long> s(sup + 1);
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    for (int d : divisor(a[i])) {
      s[d] += a[i] - a[i] / d;
    }
    int t = a[i];
    for (int e : v) {
      t = min(t, t ^ e);
    }
    if (t) {
      v.push_back(t);
    }
    sum += a[i];
  }
  int m = v.size();
  long long res = sum;
  for (int S = 1; S < 1 << m; ++S) {
    int x = 0;
    for (int j = 0; j < m; ++j) {
      if (S >> j & 1) {
        x ^= v[j];
      }
    }
    if (x <= sup) {
      res = min(res, sum - s[x]);
    }
  }
  cout << res << '\n';
}
0