結果

問題 No.937 Ultra Sword
ユーザー face4face4
提出日時 2019-11-30 10:13:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,092 bytes
コンパイル時間 663 ms
コンパイル使用メモリ 78,356 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 03:04:04
合計ジャッジ時間 8,411 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
6,816 KB
testcase_01 AC 6 ms
6,944 KB
testcase_02 AC 5 ms
6,944 KB
testcase_03 AC 6 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 335 ms
6,944 KB
testcase_06 AC 295 ms
6,944 KB
testcase_07 AC 331 ms
6,944 KB
testcase_08 AC 142 ms
6,940 KB
testcase_09 AC 107 ms
6,944 KB
testcase_10 AC 353 ms
6,944 KB
testcase_11 AC 37 ms
6,940 KB
testcase_12 AC 171 ms
6,940 KB
testcase_13 AC 160 ms
6,940 KB
testcase_14 AC 187 ms
6,940 KB
testcase_15 AC 141 ms
6,940 KB
testcase_16 AC 8 ms
6,940 KB
testcase_17 AC 19 ms
6,944 KB
testcase_18 AC 155 ms
6,940 KB
testcase_19 AC 92 ms
6,940 KB
testcase_20 AC 80 ms
6,944 KB
testcase_21 AC 382 ms
6,940 KB
testcase_22 AC 6 ms
6,944 KB
testcase_23 AC 7 ms
6,944 KB
testcase_24 AC 406 ms
6,940 KB
testcase_25 AC 243 ms
6,940 KB
testcase_26 WA -
testcase_27 AC 197 ms
6,944 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 178 ms
6,944 KB
testcase_31 AC 275 ms
6,944 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 46 ms
6,944 KB
testcase_35 AC 19 ms
6,940 KB
testcase_36 AC 230 ms
6,944 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 76 ms
6,944 KB
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 57 ms
6,944 KB
testcase_45 WA -
testcase_46 AC 115 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<numeric>
#include<cmath>
using namespace std;
typedef long long ll;

int gcd(int x, int y){
    if(x < y)   swap(x, y);
    if(y == 0)  return x;
    int cp = y;
    while((int)(log2(x)) > (int)(log2(y)))   y <<= 1;
    return gcd(cp, x^y);
}

int main(){
    int n;
    cin >> n;
    
    vector<int> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i];

    ll ans = accumulate(v.begin(), v.end(), 0ll);

    vector<ll> d(100001);
    for(int i = 0; i < n; i++){
        ll x = v[i];
        for(ll i = 1; i*i <= x; i++){
            if(x%i) continue;
            d[i] += x-x/i;
            if(i*i != x)    d[x/i] += x-i;
        }
    }

    int g = 0;
    for(int i = 0; i < n; i++)  g = gcd(g, v[i]);

    int k = 0;
    for(int i = 0; i < 18; i++) if((g>>i)&1)    k = i;

    ll sub = 0;
    for(int i = 1; i <= 100000; i++){
        int make = 0;
        for(int j = 17; j >= k; j--)    if(((i>>j)&1)==1 && ((make>>j)&1)==0)   make ^= g<<(j-k);
        if(make==i) sub = max(sub, d[i]);
    }
    
    cout << ans-sub << endl;
    return 0;
}
0