-
Notifications
You must be signed in to change notification settings - Fork 3
/
E.cpp
72 lines (64 loc) · 1.14 KB
/
E.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// LUOGU_RID: 157772382
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e7+5;
const int M=1e6+10;
int p[M],tot,mip[N];
ll mx;
bool isp[N];
void ini(){
for(int i=2;i<=mx;++i){
if(!isp[i])p[++tot]=i,mip[i]=tot;
for(int j=1;j<=tot&&p[j]*i<=mx;++j){
isp[p[j]*i]=true;
mip[p[j]*i]=j;
if(i%p[j]==0)break;
}
}
}
ll a[M],cnt[M],diff[N];
ll PinN(ll n,ll p){
ll res=0;
while(n>1){
n/=p;
res+=n;
}
return res;
}
bool check(ll x){
for(int i=1;i<=tot;++i){
if(PinN(x,p[i])<cnt[i])return false;
}
return true;
}
void llz(){
int n;
cin>>n;
ll sum=0;
for(int i=1;i<=n;++i)cin>>a[i],sum+=a[i],mx=max(mx,a[i]),diff[1]++,diff[a[i]+1]--;
for(int i=1;i<=mx;++i)diff[i]+=diff[i-1];
ini();
for(int i=1;i<=mx;++i){
int t=i;
while(t>1){
cnt[mip[t]]+=diff[i];
t/=p[mip[t]];
}
}
ll l=mx,r=sum+10;
while(l<r){
ll mid=(l+r)>>1;
if(check(mid))r=mid;
else l=mid+1;
}
cout<<l<<"\n";
}
signed main(){
iostream::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
while(T--)llz();
return 0;
}