結果
| 問題 | No.937 Ultra Sword | 
| コンテスト | |
| ユーザー |  risujiroh | 
| 提出日時 | 2019-11-29 22:35:19 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                            (最新) 
                                AC
                                 
                            (最初) | 
| 実行時間 | - | 
| コード長 | 998 bytes | 
| コンパイル時間 | 1,604 ms | 
| コンパイル使用メモリ | 175,196 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-11-21 02:27:12 | 
| 合計ジャッジ時間 | 5,966 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 45 WA * 2 | 
ソースコード
#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';
}
            
            
            
        