結果
問題 | No.937 Ultra Sword |
ユーザー | otamay6 |
提出日時 | 2019-11-20 17:45:09 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,116 bytes |
コンパイル時間 | 1,686 ms |
コンパイル使用メモリ | 173,528 KB |
実行使用メモリ | 17,096 KB |
最終ジャッジ日時 | 2024-05-01 02:17:32 |
合計ジャッジ時間 | 10,474 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | -- | - |
ソースコード
#include<bits/stdc++.h> #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; assert(2<=N&&N<=100000); int M=0, G=0; ll S=0; vector<int> A(N); REP(i,N){ cin>>A[i]; assert(1<=A[i]&&A[i]<=1000000); M=max(M, A[i]); G=GCD(G, A[i]); S += A[i]; } vector<ll> mi(M+1, 0); vector<vector<int>> div(M+1); for(int i=1;i<=M;++i){ for(int j=i;j<=M;j+=i){ div[j].push_back(i); } } REP(i,N){ for(auto y:div[A[i]]){ mi[y]+=A[i]-A[i]/y; } } ll X=S; rep(i,2,M+1) if(Usable(i,G)){ X = min(X, S-mi[i]); } cout<<X<<endl; }