//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long int;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl '\n'
int n;
bool vis[10000001];
int ind[10000001];
int re[10000001+1];
int par[100001];
int find(int no){
if(par[no]==no){
return no;
}
par[no]=find(par[no]);
return par[no];
}
vector<pair<int,int>> pre[10000001];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
int ind2=0;
vector<int> it;
for(int i=0;i<n;i++){
int x;
cin>>x;
if(vis[x]==0){
vis[x]=1;
ind[x]=ind2;
it.pb(x);
//cout<<x<<":"<<ind2<<endl;
ind2++;
}
}
for(int i=0;i<ind2;i++){
par[i]=i;
}
/*for(int i=0;i<ind2;i++){
for(int j=0;j<ind2;j++){
if(it[i]>it[j]){
pre[it[i]%it[j]].pb({i,j});
}
}
}*/
re[10000001]=-1;
for(int i=10000000;i>=1;i--){
re[i]=re[i+1];
if(vis[i]==1){
re[i]=i;
}
}
for(int i=1;i<=10000000-1;i++){
if(vis[i]==1){
for(int j=i;j<=10000000;j+=i){
if(re[j]>=0){
if(re[j]==i){
if(re[j+1]>=0){
//cout<<re[j+1]-j<<":"<<re[j+1]<<":"<<i<<endl;
pre[re[j+1]-j].pb({ind[re[j+1]],ind[i]});
continue;
}
}
pre[re[j]-j].pb({ind[re[j]],ind[i]});
}
}
}
}
llo ans=0;
for(int i=0;i<=10000000;i++){
for(auto j:pre[i]){
int x=find(j.a);
int y=find(j.b);
/*if(i==0){
cout<<it[j.a]<<","<<it[j.b]<<endl;
}*/
//cout<<j.a<<","<<j.b<<":"<<i<<endl;
if(x==y){
}
else{
ans+=i;
par[x]=y;
}
}
}
cout<<ans<<endl;
return 0;
}
Compilation message
sirni.cpp:5:19: error: declaration does not declare anything [-fpermissive]
5 | typedef long long int;
| ^~~
sirni.cpp: In function 'int main()':
sirni.cpp:76:2: error: 'llo' was not declared in this scope; did you mean 'llogb'?
76 | llo ans=0;
| ^~~
| llogb
sirni.cpp:89:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
89 | ans+=i;
| ^~~
| abs
sirni.cpp:94:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
94 | cout<<ans<<endl;
| ^~~
| abs