結果

問題 No.937 Ultra Sword
ユーザー potoooooooopotoooooooo
提出日時 2019-11-29 23:21:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,828 bytes
コンパイル時間 1,542 ms
コンパイル使用メモリ 179,592 KB
実行使用メモリ 21,344 KB
最終ジャッジ日時 2024-05-01 02:49:57
合計ジャッジ時間 6,536 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
14,208 KB
testcase_01 AC 43 ms
14,080 KB
testcase_02 AC 46 ms
14,148 KB
testcase_03 AC 45 ms
14,240 KB
testcase_04 WA -
testcase_05 AC 104 ms
14,720 KB
testcase_06 AC 120 ms
19,624 KB
testcase_07 AC 131 ms
19,748 KB
testcase_08 AC 88 ms
17,360 KB
testcase_09 AC 78 ms
16,840 KB
testcase_10 AC 137 ms
19,952 KB
testcase_11 AC 61 ms
15,688 KB
testcase_12 AC 119 ms
16,384 KB
testcase_13 AC 119 ms
16,320 KB
testcase_14 AC 126 ms
16,580 KB
testcase_15 AC 106 ms
16,320 KB
testcase_16 AC 46 ms
14,464 KB
testcase_17 AC 55 ms
15,272 KB
testcase_18 AC 113 ms
16,256 KB
testcase_19 AC 86 ms
16,000 KB
testcase_20 AC 82 ms
15,872 KB
testcase_21 AC 110 ms
21,344 KB
testcase_22 AC 48 ms
14,080 KB
testcase_23 AC 45 ms
14,208 KB
testcase_24 AC 190 ms
14,656 KB
testcase_25 AC 83 ms
14,592 KB
testcase_26 AC 90 ms
14,660 KB
testcase_27 AC 83 ms
14,592 KB
testcase_28 AC 91 ms
14,720 KB
testcase_29 AC 46 ms
14,208 KB
testcase_30 AC 86 ms
14,464 KB
testcase_31 AC 104 ms
14,784 KB
testcase_32 AC 74 ms
14,464 KB
testcase_33 AC 92 ms
14,660 KB
testcase_34 AC 52 ms
14,408 KB
testcase_35 AC 47 ms
14,188 KB
testcase_36 AC 80 ms
14,788 KB
testcase_37 AC 49 ms
14,208 KB
testcase_38 AC 78 ms
14,456 KB
testcase_39 AC 47 ms
14,080 KB
testcase_40 AC 87 ms
14,532 KB
testcase_41 AC 58 ms
14,336 KB
testcase_42 AC 75 ms
14,408 KB
testcase_43 AC 72 ms
14,404 KB
testcase_44 AC 57 ms
14,592 KB
testcase_45 AC 62 ms
14,276 KB
testcase_46 AC 66 ms
14,480 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);

    set<long long> t;
    for (int i = 0; i < min(18, (int) b.size()); i++) {
        while (b[i] && b[i] < (1 << 17)) {
            t.insert(b[i]); b[i] *= 2;
        }
    }
    vector<long long> c;
    for (auto &x: t) c.emplace_back(x);
    gj(c);
    
    long long ans = 1e18;
    for (int x = 1; x <= 100000; x++) {
        int t = x;
        for (int i = 0; i < min(18, (int) c.size()); i++) {
            if ((t ^ c[i]) < t) t ^= c[i];
        }
        if (t == 0) ans = min(ans, sum[x]);
    }
    cout << ans << endl;
    return 0;
}
0