QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#298146 | #4634. Factor | defyers# | TL | 2020ms | 15876kb | C++14 | 1.0kb | 2024-01-05 18:36:51 | 2024-01-05 18:36:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define LL long long
vector<int> prime;
void find_prime(int n) {
vector<int> lp(n, 0);
for (int i = 2; i <= n; i++) {
if (lp[i] == 0) { lp[i] = i; prime.push_back(i); }
for (int j = 0; i * prime[j] <= n; j++) {
lp[i * prime[j]] = prime[j];
if (prime[j] == lp[i]) break; } } return;
}
LL n;
LL ans = 0;
void f(LL sum, LL num, int pl) {
ans++;
//cout << "num=" << num << endl;
for (int i = pl; i < prime.size(); i++) {
if (num < prime[i] || sum + 1 < prime[i]) break;
LL tmp = prime[i];
LL add = 1 + prime[i];
while (tmp <= num) {
f(min((LL)1e7, sum * add), num / tmp, i + 1);
tmp *= prime[i];
add += tmp;
add = min(add, (LL)1e7);
}
}
}
void solve() {
cin >> n;
f(1, n, 0); // prime[0] = 2
cout << ans << "\n";
return;
}
int main() {
ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
cout << fixed << setprecision(10);
find_prime(3e6);
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 14ms
memory: 15844kb
input:
10
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 9ms
memory: 15668kb
input:
20
output:
9
result:
ok single line: '9'
Test #3:
score: 0
Accepted
time: 10ms
memory: 15820kb
input:
50
output:
17
result:
ok single line: '17'
Test #4:
score: 0
Accepted
time: 11ms
memory: 15876kb
input:
6
output:
4
result:
ok single line: '4'
Test #5:
score: 0
Accepted
time: 13ms
memory: 15676kb
input:
87
output:
26
result:
ok single line: '26'
Test #6:
score: 0
Accepted
time: 11ms
memory: 15820kb
input:
609
output:
130
result:
ok single line: '130'
Test #7:
score: 0
Accepted
time: 9ms
memory: 15868kb
input:
5126
output:
806
result:
ok single line: '806'
Test #8:
score: 0
Accepted
time: 10ms
memory: 15672kb
input:
92180
output:
10905
result:
ok single line: '10905'
Test #9:
score: 0
Accepted
time: 14ms
memory: 15836kb
input:
984096
output:
95960
result:
ok single line: '95960'
Test #10:
score: 0
Accepted
time: 12ms
memory: 15868kb
input:
5744387
output:
494209
result:
ok single line: '494209'
Test #11:
score: 0
Accepted
time: 27ms
memory: 15800kb
input:
51133311
output:
3851066
result:
ok single line: '3851066'
Test #12:
score: 0
Accepted
time: 191ms
memory: 15672kb
input:
607519174
output:
40319008
result:
ok single line: '40319008'
Test #13:
score: 0
Accepted
time: 2020ms
memory: 15836kb
input:
7739876803
output:
456270136
result:
ok single line: '456270136'
Test #14:
score: -100
Time Limit Exceeded
input:
80754680817