QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#51611 | #4634. Factor | Hongzy | RE | 0ms | 0kb | C++ | 1.1kb | 2022-10-02 23:41:57 | 2022-10-02 23:41:59 |
Judging History
answer
#include <bits/stdc++.h>
#define LOG(FMT...) fprintf(stderr, FMT);
#define rep(i, j, k) for(int i = j; i <= k; ++ i)
#define per(i, j, k) for(int i = j; i >= k; -- i)
using namespace std;
typedef long long ll;
const int N = 3e6 + 10;
bool tag[N];
int p[N], pc, s[N];
void sieve(int n) {
rep(i, 2, n) {
if(!tag[i]) p[++ pc] = i;
s[i] = s[i-1] + (!tag[i]);
for(int j = 1; j <= pc && i * p[j] <= n; j ++) {
tag[i * p[j]] = 1;
if(i % p[j] == 0) break ;
}
}
}
int range(int x, int y) {
return x > y ? 0 : s[y] - s[x-1];
}
ll n, ans = 1;
void dfs(ll x, ll s, int id) {
for(int i = id + 1; p[i] <= s+1 && x * p[i] <= n; i ++) {
if(x * p[i] * p[i] > n) {
ans += range(p[i], min(s+1, n / x));
break;
}
ans++;
ll z = 1, s0 = 1;
rep(j, 1, 50) {
z *= p[i], s0 += z;
if(x * z > n) break;
dfs(x * z, s * s0, i);
if(j >= 2)
++ans;
}
}
}
int main() {
sieve(5e6);
scanf("%lld", &n);
dfs(1, 1, 0);
printf("%lld\n", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
10