結果

問題 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
コンパイル時間 1,613 ms
コンパイル使用メモリ 173,652 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-13 09:01:01
合計ジャッジ時間 6,375 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 183 ms
4,380 KB
testcase_06 AC 107 ms
4,380 KB
testcase_07 AC 117 ms
4,380 KB
testcase_08 AC 56 ms
4,380 KB
testcase_09 AC 44 ms
4,380 KB
testcase_10 AC 129 ms
4,380 KB
testcase_11 AC 13 ms
4,376 KB
testcase_12 AC 58 ms
4,380 KB
testcase_13 AC 56 ms
4,376 KB
testcase_14 AC 64 ms
4,376 KB
testcase_15 AC 49 ms
4,380 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 53 ms
4,388 KB
testcase_19 AC 32 ms
4,384 KB
testcase_20 AC 28 ms
4,380 KB
testcase_21 AC 135 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 283 ms
4,380 KB
testcase_25 AC 110 ms
4,380 KB
testcase_26 AC 110 ms
4,376 KB
testcase_27 AC 95 ms
4,380 KB
testcase_28 AC 101 ms
4,380 KB
testcase_29 AC 5 ms
4,384 KB
testcase_30 AC 95 ms
4,376 KB
testcase_31 AC 145 ms
4,376 KB
testcase_32 AC 78 ms
4,380 KB
testcase_33 AC 131 ms
4,376 KB
testcase_34 AC 20 ms
4,376 KB
testcase_35 AC 11 ms
4,380 KB
testcase_36 AC 101 ms
4,380 KB
testcase_37 AC 10 ms
4,380 KB
testcase_38 AC 88 ms
4,380 KB
testcase_39 AC 6 ms
4,376 KB
testcase_40 AC 108 ms
4,376 KB
testcase_41 AC 36 ms
4,376 KB
testcase_42 AC 82 ms
4,380 KB
testcase_43 AC 75 ms
4,380 KB
testcase_44 AC 27 ms
4,376 KB
testcase_45 AC 48 ms
4,376 KB
testcase_46 AC 50 ms
4,380 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