QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#51612 | #4634. Factor | Hongzy | AC ✓ | 1110ms | 19304kb | C++ | 1.1kb | 2022-10-02 23:42:12 | 2022-10-02 23:42:13 |
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(3e6);
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: 100
Accepted
time: 27ms
memory: 19304kb
input:
10
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 19ms
memory: 19264kb
input:
20
output:
9
result:
ok single line: '9'
Test #3:
score: 0
Accepted
time: 27ms
memory: 19256kb
input:
50
output:
17
result:
ok single line: '17'
Test #4:
score: 0
Accepted
time: 15ms
memory: 19224kb
input:
6
output:
4
result:
ok single line: '4'
Test #5:
score: 0
Accepted
time: 19ms
memory: 19304kb
input:
87
output:
26
result:
ok single line: '26'
Test #6:
score: 0
Accepted
time: 25ms
memory: 19192kb
input:
609
output:
130
result:
ok single line: '130'
Test #7:
score: 0
Accepted
time: 21ms
memory: 19188kb
input:
5126
output:
806
result:
ok single line: '806'
Test #8:
score: 0
Accepted
time: 17ms
memory: 19264kb
input:
92180
output:
10905
result:
ok single line: '10905'
Test #9:
score: 0
Accepted
time: 13ms
memory: 19204kb
input:
984096
output:
95960
result:
ok single line: '95960'
Test #10:
score: 0
Accepted
time: 13ms
memory: 19284kb
input:
5744387
output:
494209
result:
ok single line: '494209'
Test #11:
score: 0
Accepted
time: 13ms
memory: 19240kb
input:
51133311
output:
3851066
result:
ok single line: '3851066'
Test #12:
score: 0
Accepted
time: 23ms
memory: 19264kb
input:
607519174
output:
40319008
result:
ok single line: '40319008'
Test #13:
score: 0
Accepted
time: 51ms
memory: 19260kb
input:
7739876803
output:
456270136
result:
ok single line: '456270136'
Test #14:
score: 0
Accepted
time: 189ms
memory: 19256kb
input:
80754680817
output:
4304423738
result:
ok single line: '4304423738'
Test #15:
score: 0
Accepted
time: 1110ms
memory: 19304kb
input:
1000000000000
output:
48366248808
result:
ok single line: '48366248808'
Test #16:
score: 0
Accepted
time: 517ms
memory: 19184kb
input:
300000000000
output:
15176932897
result:
ok single line: '15176932897'
Test #17:
score: 0
Accepted
time: 687ms
memory: 19200kb
input:
500000000000
output:
24808936807
result:
ok single line: '24808936807'
Test #18:
score: 0
Accepted
time: 885ms
memory: 19264kb
input:
700000000000
output:
34300642547
result:
ok single line: '34300642547'
Test #19:
score: 0
Accepted
time: 951ms
memory: 19296kb
input:
790673894439
output:
38570752521
result:
ok single line: '38570752521'