Problem Statement Let us regard an integer k k as "similar to 250 250" if the following…
- User
Problem Statement Let us regard an integer k k as "similar to 250 250" if the following condition is satisfied:
k k is represented as k
p × q 3 k=p×q 3 with primes p < q p<q. How many integers less than or equal to N N are "similar to 250 250"?
Constraints N N is an integer between 1 1 and 1 0 18 10 18 (inclusive) Input Input is given from Standard Input in the following format:
N N Output Print the answer as an integer.
Sample 1 Inputcopy Outputcopy 250 2 54
2 × 3 3 54=2×3 3 is "similar to 250 250". 250
2 × 5 3 250=2×5 3 is "similar to 250 250". The two integers above are all the integers "similar to 250 250".
Sample 2 Inputcopy Outputcopy 1 0 Sample 3 Inputcopy Outputcopy 123456789012345 226863 #include <bits/stdc++.h>
using namespace std;
#define ll long long #define ld long double #define endl '\n' #define pb push_back #define speedyboy ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define all(x) x.begin() , x.end() #define F first #define S second #define pll pair<ll , ll> #define pss pair<string , string> #define YES cout << "YES" << endl; #define NO cout << "NO" << endl;
ll i , j , k; const ll sz = 5e5 + 5 , INF = 1e9 , MOD = 998244353; bool primes[sz];
void solve(){ vector v; ll n , sum = 0; cin >> n; for(i = 2 ; i * i <= n ; i++){ if(!primes[i]){ v.pb(i); for(j = i * i ; j <= n ; j += i){ primes[j] = true; } } } for(i = 0 ; i < v.size() ; i++){ ll x = n / (v[i] * v[i] * v[i]); sum += upper_bound(v.begin() , v.begin() + i , x) - v.begin(); } cout << sum << endl; }
signed main(){ speedyboy; ll t = 1; //cin >> t; while(t--){ solve(); } } What is wrong with my code?
- Assistant