結果

問題 No.937 Ultra Sword
ユーザー potoooooooopotoooooooo
提出日時 2019-11-29 22:54:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,565 bytes
コンパイル時間 1,833 ms
コンパイル使用メモリ 178,964 KB
実行使用メモリ 21,348 KB
最終ジャッジ日時 2024-05-01 02:46:10
合計ジャッジ時間 8,092 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
14,276 KB
testcase_01 WA -
testcase_02 AC 61 ms
14,208 KB
testcase_03 AC 65 ms
14,152 KB
testcase_04 WA -
testcase_05 AC 127 ms
14,660 KB
testcase_06 AC 162 ms
19,492 KB
testcase_07 AC 187 ms
19,748 KB
testcase_08 AC 116 ms
17,476 KB
testcase_09 AC 108 ms
16,836 KB
testcase_10 AC 195 ms
20,028 KB
testcase_11 AC 79 ms
15,668 KB
testcase_12 AC 141 ms
16,328 KB
testcase_13 AC 138 ms
16,252 KB
testcase_14 AC 150 ms
16,492 KB
testcase_15 AC 129 ms
16,320 KB
testcase_16 AC 62 ms
14,464 KB
testcase_17 AC 74 ms
15,272 KB
testcase_18 AC 135 ms
16,224 KB
testcase_19 AC 108 ms
16,000 KB
testcase_20 AC 99 ms
16,068 KB
testcase_21 AC 138 ms
21,348 KB
testcase_22 AC 58 ms
14,148 KB
testcase_23 AC 56 ms
14,148 KB
testcase_24 AC 220 ms
14,848 KB
testcase_25 AC 103 ms
14,592 KB
testcase_26 AC 112 ms
14,536 KB
testcase_27 AC 105 ms
14,452 KB
testcase_28 AC 108 ms
14,720 KB
testcase_29 AC 59 ms
14,208 KB
testcase_30 AC 109 ms
14,592 KB
testcase_31 AC 127 ms
14,788 KB
testcase_32 AC 103 ms
14,532 KB
testcase_33 AC 118 ms
14,720 KB
testcase_34 AC 71 ms
14,404 KB
testcase_35 AC 62 ms
14,272 KB
testcase_36 AC 110 ms
14,656 KB
testcase_37 AC 62 ms
14,404 KB
testcase_38 AC 103 ms
14,464 KB
testcase_39 AC 71 ms
14,336 KB
testcase_40 AC 111 ms
14,592 KB
testcase_41 AC 77 ms
14,256 KB
testcase_42 AC 104 ms
14,404 KB
testcase_43 AC 95 ms
14,336 KB
testcase_44 AC 75 ms
14,592 KB
testcase_45 AC 89 ms
14,272 KB
testcase_46 AC 85 ms
14,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<int> dv[100010];
long long sum[100010];

void calc_div() {
    for (int i = 2; i <= 100000; i++) {
        for (int j = i; j <= 100000; j += i) {
            dv[j].emplace_back(i);
        }
    }
}

void gj(vector<long long> &v) {
    int pv = 0; int n = v.size();
    for (int k = 16; k >= 0; k--) {
        for (int i = pv; i < n; i++) {
            if (v[i] & (1 << k)) {
                swap(v[pv], v[i]);
                break;
            }
        }
        if (v[pv] & (1 << k)) {
            for (int i = 0; i < n; i++) {
                if (i == pv) continue;
                if (v[i] & (1 << k)) {
                    v[i] ^= v[pv];
                }
            }
            pv++;
        }
    }
}

int main() {
    calc_div();
    int n; cin >> n;
    long long all = 0;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i]; all += a[i];
        for (auto &d: dv[a[i]]) sum[d] -= a[i] - a[i] / d;
    }
    for (int i = 0; i <= 100000; i++) sum[i] += all;
    set<long long> s;
    for (int i = 0; i < n; i++) {
        while (a[i] < (1 << 17)) {
            s.insert(a[i]); a[i] *= 2;
        }
    }
    vector<long long> b;
    for (auto &x: s) b.emplace_back(x);
    gj(b);
    long long ans = 1e18;
    for (int x = 1; x <= 100000; x++) {
        int t = x;
        for (int i = 0; i < min(17, (int) b.size()); i++) {
            if ((t ^ b[i]) < t) t ^= b[i];
        }
        if (t == 0) ans = min(ans, sum[x]);
    }
    cout << ans << endl;
    return 0;
}
0