# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
78858 | tmwilliamlin168 | Toys (CEOI18_toy) | C++14 | 2226 ms | 17540 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.
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> p, ans;
void dfs(int x, vector<int> &p, int i, int s) {
ans.push_back(s+x-1);
vector<int> p2;
for(; i<p.size(); ++i)
if(x%p[i]==0)
p2.push_back(p[i]);
for(i=0; i<p2.size(); ++i)
if(x/p2[i]>=p2[i])
dfs(x/p2[i], p2, i, s+p2[i]-1);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i=2; i*i<=n; ++i)
if(n%i==0)
p.push_back(i);
dfs(n, p, 0, 0);
// cout << ans.size() << endl;
sort(ans.begin(), ans.end());
ans.resize(unique(ans.begin(), ans.end())-ans.begin());
cout << ans.size() << "\n";
for(int ai : ans)
cout << ai << " ";
}
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... |