結果

問題 No.937 Ultra Sword
ユーザー pekempeypekempey
提出日時 2019-11-29 22:25:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 63 ms / 3,000 ms
コード長 1,310 bytes
コンパイル時間 1,571 ms
コンパイル使用メモリ 169,552 KB
実行使用メモリ 4,756 KB
最終ジャッジ日時 2023-08-13 08:56:37
合計ジャッジ時間 4,958 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 7 ms
4,376 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 38 ms
4,756 KB
testcase_06 AC 51 ms
4,380 KB
testcase_07 AC 57 ms
4,708 KB
testcase_08 AC 28 ms
4,380 KB
testcase_09 AC 23 ms
4,380 KB
testcase_10 AC 61 ms
4,560 KB
testcase_11 AC 15 ms
4,380 KB
testcase_12 AC 53 ms
4,708 KB
testcase_13 AC 51 ms
4,636 KB
testcase_14 AC 59 ms
4,588 KB
testcase_15 AC 45 ms
4,392 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 10 ms
4,384 KB
testcase_18 AC 49 ms
4,380 KB
testcase_19 AC 31 ms
4,380 KB
testcase_20 AC 28 ms
4,376 KB
testcase_21 AC 63 ms
4,720 KB
testcase_22 AC 6 ms
4,380 KB
testcase_23 AC 6 ms
4,376 KB
testcase_24 AC 60 ms
4,556 KB
testcase_25 AC 46 ms
4,580 KB
testcase_26 AC 39 ms
4,380 KB
testcase_27 AC 38 ms
4,376 KB
testcase_28 AC 44 ms
4,448 KB
testcase_29 AC 6 ms
4,376 KB
testcase_30 AC 34 ms
4,376 KB
testcase_31 AC 50 ms
4,644 KB
testcase_32 AC 30 ms
4,504 KB
testcase_33 AC 49 ms
4,576 KB
testcase_34 AC 13 ms
4,380 KB
testcase_35 AC 8 ms
4,380 KB
testcase_36 AC 44 ms
4,640 KB
testcase_37 AC 9 ms
4,376 KB
testcase_38 AC 35 ms
4,380 KB
testcase_39 AC 7 ms
4,380 KB
testcase_40 AC 39 ms
4,380 KB
testcase_41 AC 18 ms
4,380 KB
testcase_42 AC 31 ms
4,376 KB
testcase_43 AC 29 ms
4,380 KB
testcase_44 AC 14 ms
4,376 KB
testcase_45 AC 21 ms
4,380 KB
testcase_46 AC 23 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
 
#define rep(i, n)      for (int i = 0; i < (n); i++)
#define repr(i, n)     for (int i = (n) - 1; i >= 0; i--)
#define repe(i, l, r)  for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define repi(i, l, r)  for (int i = (l); i <= (r); i++)
#define repir(i, l, r) for (int i = (r); i >= (l); i--)
#define range(a) a.begin(), a.end()
void initio() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

int main() { initio();
  int N; cin >> N;
  vector<ll> A(N); rep(i, N) cin >> A[i];
  vector<ll> kitei;
  for (ll x : A) {
    for (int i = 0; i < 17; i++) {
      ll y = x << i;
      for (ll z : kitei) y = min(y, y ^ z);
      if (y != 0) {
        kitei.push_back(y);
      }
    }
  }
  auto can = [&](ll x) {
    for (ll z : kitei) x = min(x, x ^ z);
    return x == 0;
  };
  vector<ll> sum(100001);
  for (ll x : A) sum[x] += x;
  ll ans = LLONG_MAX;
  for (int i = 1; i <= 100000; i++) {
    for (int j = i * 2; j <= 100000; j += i) {
      sum[i] += sum[j];
    }
  }
  ll total = 0;
  for (ll x : A) total += x;
  for (int i = 1; i <= 100000; i++) {
    if (can(i)) {
      ans = min(ans, total - sum[i] + sum[i] / i);
    }
  }
  cout << ans << endl;
}
0