# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
536885 | siewjh | Toys (CEOI18_toy) | C++17 | 2572 ms | 90940 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 main(){
int n; cin >> n;
int sqrtn = sqrt(n);
vector<int> fact;
for (int i = 1; i <= sqrtn; i++)
if (n % i == 0){
fact.push_back(i);
if (n / i != i) fact.push_back(n / i);
}
sort(fact.begin(), fact.end());
int fnum = fact.size();
vector<vector<int>> ffact(fact.size());
for (int i = 0; i < fnum; i++)
for (int j = 0; j < i; j++)
if (fact[i] % fact[j] == 0)
ffact[i].push_back(j);
vector<set<int>> cumsum(fact.size());
cumsum[0].insert(0);
for (int i = 0; i < fnum; i++)
for (int j = 0; j < ffact[i].size(); j++)
for (int csv : cumsum[ffact[i][j]])
cumsum[i].insert(csv + fact[i] / fact[ffact[i][j]] - 1);
set<int> ans;
for (int csv : cumsum.back()) ans.insert(csv);
cout << ans.size() << '\n';
for (int x : ans) cout << x << ' ';
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... |