-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathH_Mud_Holes_Avoidance.cpp
More file actions
58 lines (44 loc) · 851 Bytes
/
H_Mud_Holes_Avoidance.cpp
File metadata and controls
58 lines (44 loc) · 851 Bytes
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
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ll long long
void solve() {
ll n;cin>>n;
vector<ll>v(n+2);
ll mx=-1ll;
for(int i = 1; i <= n; ++i){
cin>>v[i];
mx=max(mx,v[i]);
}
vector<bool>arr(mx+1,false);
for (int i = 1; i <= n; i++)
{
arr[v[i]]=true;
}
// for (auto i = 1; i <=mx; i++)
// {
// cout<<arr[i]<<" ";
// }
for (int i = 2; i <=mx; i++)
{
if(arr[i]) continue;
bool ch=true;
for(int j = i; j <= mx; j+=i){
if(arr[j]){
ch=false;
break;
}
}
if(ch){
cout<<i<<endl;
return;
}
}
cout<<mx+1<<endl;
}
int32_t main() {
int t = 1; //cin >> t;
while(t--) {
solve();
}
}