2 条题解
-
0
首先根据题意我们知道,因为 ,所以 最大不超过 。 然后分析 的组成,可以发现需要用到的最大质数不超过 ,即 。那么直接预处理出 范围内的质数,然后计算即可。
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; LL primes[N],cnt;bool st[N]; inline void get_P(LL x) { for(LL i = 2;i <= x;i++) { if(!st[i]){primes[++cnt] = i;} for(int j = 1;j <= cnt && primes[j] * i <= x;j++) { st[primes[j] * i] = true; if(i % primes[j] == 0) break; } } return ; } inline bool check(LL x,LL lm) {return x <= cnt && primes[x] * primes[x] * primes[x] <= lm;} inline LL v(LL x){return x * x * x;} int main() { LL n;cin >> n; LL res = 0; get_P(1000000); for(LL i = 1;check(i,n);i++) for(int j=1;j<=cnt&&primes[j]<primes[i]&&primes[j]*v(primes[i])<=n;j++) res++; cout << res << endl; return 0; }
信息
- ID
- 20990
- 时间
- 2000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- (无)
- 递交数
- 107
- 已通过
- 17
- 上传者