# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
594828 | penguinhacker | Toys (CEOI18_toy) | C++17 | 1742 ms | 86968 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;
#define ll long long
#define ar array
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> f;
for (int i=1; i*i<=n; ++i) {
if (n%i==0) {
f.push_back(i);
if (i*i<n)
f.push_back(n/i);
}
}
sort(f.begin(), f.end());
set<int> dp[f.size()];
dp[0]={0};
for (int i=1; i<f.size(); ++i) {
dp[i]={f[i]-1};
for (int j=1; j<i; ++j)
if (f[i]%f[j]==0) {
int pos=lower_bound(f.begin(), f.end(), f[i]/f[j])-f.begin();
for (int x : dp[pos])
dp[i].insert(x+f[j]-1);
}
//cout << f[i] << endl;
}
vector<int> ans(dp[f.size()-1].begin(), dp[f.size()-1].end());
cout << ans.size() << "\n";
for (int i : ans)
cout << i << " ";
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... |