Advertisement
7oSkaaa

Different Divisors

Aug 10th, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1.   #include <bits/stdc++.h>
  2.   using namespace std;
  3.  
  4.   #define cin(vec) for(auto& i : vec) cin >> i
  5.   #define cout(vec) for(auto& i : vec) cout << i << " "; cout << "\n";
  6.   #define read_2d(vec, n, m) for(int i = 0; i < n; i++) for(int j = 0; j < m && cin >> nums[i][j]; j++);
  7.   #define loop(a, b, c) for(int i = a ; i < (b); i += c)
  8.   #define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
  9.   #define all(vec) vec.begin(),vec.end()
  10.   #define rall(vec) vec.rbegin(),vec.rend()
  11.   #define sz size()
  12.   #define Pair pair <int,int>
  13.   #define ll long long
  14.   #define ull unsigned long long
  15.   #define Mod 1'000'000'007
  16.   #define INF 2000'000'000
  17.   #define PI 3.14159
  18.  
  19.   void Code_Crush(){
  20.     ios_base::sync_with_stdio(false);   cin.tie(nullptr);   cout.tie(nullptr);
  21.   #ifndef ONLINE_JUDGE
  22.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  23.   #endif
  24.   }
  25.   vector <bool> primes(1e6 + 1, true);
  26.   vector <int> prime;
  27.   void Sieve(){  
  28.     for (ll i = 2, k = 0; i <= (1e6 + 1); i++){
  29.         if (primes[i]){
  30.             prime.push_back(i);
  31.             for (ll j = i * i; j <= (1e6 + 1); j += i) primes[j] = false;
  32.         }
  33.     }  
  34.   }
  35.  
  36.   int main(){
  37.     Code_Crush();
  38.     Sieve();
  39.     int t;                  cin >> t;
  40.     while(t--){
  41.         ll d;              cin >> d;
  42.         ll first = *upper_bound(all(prime), d);
  43.         ll second = *lower_bound(all(prime), d + first);
  44.         cout << first * second << "\n";
  45.     }
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement