Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- bool nums[2000005];
- int primes(){
- int i;
- for(i = 2; i <= 2000005; i++){
- if (!nums[i]){
- for(int j = i*i; j <= 2000005; j += i) nums[j] = 0;
- }else return i-1;
- }
- return i;
- }
- int main(){
- int casos;
- cin >> casos;
- while(casos--){
- memset(nums, 1,sizeof nums);
- int num;
- cin >> num;
- while (num--){
- int aux;
- cin >> aux;
- nums[aux] = 0;
- }
- if (nums[1] != 0) cout << 0 << endl;
- else cout << primes() << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement