結果

問題 No.937 Ultra Sword
ユーザー otamay6otamay6
提出日時 2019-11-20 17:44:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,064 bytes
コンパイル時間 815 ms
コンパイル使用メモリ 72,008 KB
実行使用メモリ 12,208 KB
最終ジャッジ日時 2023-08-13 08:38:49
合計ジャッジ時間 9,333 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
using ll = long long;

int GCD(int x,int y){
    if(x>y) swap(x,y);
    int Lx=32-__builtin_clz(x),Ly=32-__builtin_clz(y);
    return x?GCD(x,y^(x<<(Ly-Lx))):y;
}

bool Usable(int x,int g){
    int Lx=32-__builtin_clz(x),Lg=32-__builtin_clz(g);
    while(Lx>=Lg){
        x^=g<<(Lx-Lg);
        Lx=32-__builtin_clz(x);
    }
    return x==0;
}

int main(){
    int N;cin>>N;
    int M=0, G=0;
    ll S=0;
    vector<int> A(N);
    REP(i,N){
        cin>>A[i];
        M=max(M, A[i]);
        G=GCD(G, A[i]);
        S += A[i];
    }
    vector<ll> mi(M+1, 0);
    REP(i,N){
        for(int j=1;j*j<=A[i];++j){
            if(A[i]%j==0){
                mi[j] += A[i] - A[i]/j;
                if(j*j != A[i]){
                    mi[A[i]/j] += A[i]-j;
                }
            }
        }
    }
    ll X=S;
    rep(i,2,M+1) if(Usable(i,G)){
        X = min(X, S-mi[i]);
    }
    cout<<X<<endl;
}
0