# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
78857 | tmwilliamlin168 | Toys (CEOI18_toy) | C++14 | 5035 ms | 9420 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> ps, ans;
void dfs(int x, int i, int s) {
ans.push_back(x-1+s);
for(; i<ps.size(); ++i)
if(x%ps[i]==0&&x/ps[i]>=ps[i])
dfs(x/ps[i], i, s+ps[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)
ps.push_back(i);
dfs(n, 0, 0);
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... |