Advertisement
Manioc

Jaida vagabunda

Oct 26th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. bool nums[2000005];
  5.  
  6. int primes(){
  7.     int i;
  8.     for(i = 2; i <= 2000005; i++){
  9.         if (!nums[i]){
  10.             for(int j = i*i; j <= 2000005; j += i) nums[j] = 0;
  11.         }else return i-1;
  12.     }
  13.     return i;
  14. }
  15.  
  16. int main(){
  17.     int casos;
  18.     cin >> casos;
  19.     while(casos--){
  20.         memset(nums, 1,sizeof nums);
  21.         int num;
  22.         cin >> num;
  23.         while (num--){
  24.             int aux;
  25.             cin >> aux;
  26.             nums[aux] = 0;
  27.         }
  28.         if (nums[1] != 0) cout << 0 << endl;
  29.         else cout << primes() << endl;
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement