# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
161940 | Akashi | Toys (CEOI18_toy) | C++14 | 3321 ms | 87292 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
int n, k = 1;
map <int, int> f;
set <int> s[10005];
void solve(int n, int K){
s[K].insert(n - 1);
int r = sqrt(n);
for(int i = 2; i <= r ; ++i){
if(n % i) continue ;
if(f[i] == 0){
++k;
f[i] = k;
solve(i, k);
}
if(f[n / i] == 0){
++k;
f[n / i] = k;
solve(n / i, k);
}
int x1 = f[i];
int x2 = f[n / i];
for(auto it : s[x1])
s[K].insert(it + n / i - 1);
for(auto it : s[x2])
s[K].insert(it + i - 1);
}
}
int main()
{
// freopen("1.in", "r", stdin);
scanf("%d", &n);
f[n] = 1;
solve(n, 1);
printf("%d\n", s[1].size());
for(auto it : s[1])
printf("%d ", it);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |