Advertisement
pedrocasdev

Untitled

Aug 5th, 2022
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4. using namespace __gnu_pbds;
  5. using namespace std;
  6.  
  7. #define ordered_set tree<pair<int, int>, null_type,less<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>
  8. typedef long long ll;
  9. const long long mod = 1000000007;
  10. ll gcd (ll a, ll b) {return b==0 ? a : gcd(b, a%b);}
  11.  
  12. #define all(c) (c).begin(),(c).end()
  13. #define pb push_back
  14. #define mp make_pair
  15. #define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
  16. #define debug_vector(v, n) for(int i = 0; i<n; i++)cout<< v[i] << " \n"[i == n-1]
  17.  
  18. const int maxn = 1e7;
  19. ll divs[maxn+1], quant[9][maxn+1];
  20. bool prime[maxn];
  21. void sieve()
  22. {
  23.     for (ll i = 0; i <=maxn; i++)
  24.       prime[i] = 1;
  25.     for (ll p = 2; p * p <= maxn; p++)
  26.     {
  27.       if(prime[p] == true)
  28.       {
  29.         for(ll i = p; i <= maxn; i += p){
  30.           prime[i] = false;
  31.           divs[i]+=1;
  32.         }
  33.       }
  34.     }
  35. }
  36.  
  37. int main()
  38. {
  39. #ifdef LOCAL
  40.     freopen("input.txt", "rt", stdin);
  41.     freopen("output.txt", "wt", stdout);
  42. #endif
  43.     //freopen("homework_input.txt", "rt", stdin);
  44.     //freopen("output.txt", "wt", stdout);
  45.     fastio
  46.     sieve();
  47.     for(ll i =1; i<=maxn; i++){
  48.         for(ll j =1; j<=8; j++){
  49.             if(divs[i] == j)
  50.                 quant[j][i] = 1;
  51.             else
  52.                 quant[j][i] = 0;
  53.         }
  54.     }
  55.     for(ll i = 1; i<=8; i++){
  56.         quant[i][1]=quant[i][1];
  57.         for(ll j = 2; j<=maxn; j++){
  58.             quant[i][j]+=quant[i][j-1];
  59.         }
  60.     }
  61.     int tc;
  62.     cin >> tc;
  63.     int i = 1;
  64.     while(tc--){
  65.         ll a, b, k;
  66.         cin >> a >> b >> k;
  67.         ll ans = 0;
  68.         if(k > 8)cout<<"Case #"<<i<<": " << ans<<endl;
  69.         else cout<<"Case #"<<i<<": " << quant[k][b] - quant[k][a-1]<<endl;
  70.         i++;
  71.     }
  72.     return 0;
  73. }
  74.  
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement