結果

問題 No.937 Ultra Sword
ユーザー face4face4
提出日時 2019-11-30 09:46:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 888 bytes
コンパイル時間 678 ms
コンパイル使用メモリ 77,444 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 03:03:44
合計ジャッジ時間 8,934 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 351 ms
6,944 KB
testcase_06 AC 311 ms
6,940 KB
testcase_07 AC 338 ms
6,940 KB
testcase_08 AC 150 ms
6,944 KB
testcase_09 AC 111 ms
6,940 KB
testcase_10 AC 383 ms
6,940 KB
testcase_11 AC 34 ms
6,940 KB
testcase_12 AC 174 ms
6,940 KB
testcase_13 AC 168 ms
6,944 KB
testcase_14 AC 193 ms
6,940 KB
testcase_15 AC 141 ms
6,940 KB
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 15 ms
6,944 KB
testcase_18 AC 158 ms
6,940 KB
testcase_19 AC 92 ms
6,940 KB
testcase_20 AC 80 ms
6,944 KB
testcase_21 AC 401 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 422 ms
6,940 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 214 ms
6,944 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 188 ms
6,944 KB
testcase_31 AC 295 ms
6,940 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 48 ms
6,940 KB
testcase_35 AC 20 ms
6,944 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 AC 62 ms
6,940 KB
testcase_45 WA -
testcase_46 AC 121 ms
6,944 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]);

    ll sub = 0;
    for(int i = 1; i*g <= 100000; i++){
        sub = max(sub, d[i*g]);
    }
    cout << ans-sub << endl;
    return 0;
}
0