# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1053484 | VMaksimoski008 | Toys (CEOI18_toy) | C++17 | 1254 ms | 86512 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;
vector<int> div;
for(int i=1; i*i<=n; i++) {
if(n % i > 0) continue;
div.push_back(i);
if(n / i != i) div.push_back(n/i);
}
map<int, int> mp;
sort(div.begin(), div.end());
for(int i=0; i<div.size(); i++) mp[div[i]] = i;
int m = div.size();
set<int> dp[m]; dp[0].insert(0);
for(int i=1; i<m; i++) {
for(int j=1; j*j<=div[i]; j++) {
if(div[i] % j == 0 && j > 1)
for(auto &x : dp[mp[div[i]/j]]) dp[i].insert(x+j-1);
if(div[i] % j == 0 && div[i] / j > 1)
for(auto &x : dp[mp[j]]) dp[i].insert(x+(div[i]/j)-1);
}
}
cout << dp[m-1].size() << '\n';
for(auto &x : dp[m-1]) 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... |