fork download
  1. #include <bits/stdc++.h>
  2. #define FNAME "CANDY"
  3. using namespace std;
  4. const int MAXN = 1e6 + 1;
  5. typedef long long ll;
  6. const long long MOD = 1e9 + 7;
  7.  
  8. void fastip() {
  9. ios_base::sync_with_stdio(0);
  10. cin.tie(0); cout.tie(0);
  11. if (fopen(FNAME".inp", "r")) {
  12. freopen(FNAME".inp", "r", stdin);
  13. freopen(FNAME".out", "w", stdout);
  14. }
  15. }
  16.  
  17. int n;
  18. vector<int> Sieve(MAXN, 1);
  19.  
  20. void Sieve_build(){
  21. Sieve[0] = Sieve[1] = 0;
  22. for(int i = 2; i <= sqrt(MAXN); i++){
  23. if(Sieve[i] == 1){
  24. for(int j = i * i; j <= MAXN; j += i){
  25. Sieve[j] = 0;
  26. }
  27. }
  28. }
  29. }
  30.  
  31. int main(){
  32. fastip();
  33. Sieve_build();
  34.  
  35. cin >> n;
  36.  
  37. unordered_map<int,int> mp;
  38.  
  39. int Mini = 1e9;
  40. int Maxi = 0;
  41.  
  42. for(int i = 0; i < n ; i++){
  43. int a;
  44. cin >> a;
  45. mp[a]++;
  46. Mini = min(Mini, a);
  47. Maxi = max(Maxi, a);
  48. }
  49.  
  50. int check = false;
  51.  
  52. for(int i = Mini; i <= Maxi ; i++){
  53. if(Sieve[i] == 1 && mp[i] == 0){
  54. cout << i;
  55. check = true;
  56. break;
  57. }
  58. }
  59.  
  60. if(!check){
  61. cout << "No prime number missing!";
  62. }
  63.  
  64. return 0;
  65. }
Success #stdin #stdout 0.01s 6940KB
stdin
Standard input is empty
stdout
No prime number missing!