# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
426306 | fskarica | Toys (CEOI18_toy) | C++14 | 1347 ms | 114496 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 fi first
#define se second
const int MAX = 2e5 + 10;
int n;
vector <int> v;
vector <int> dp[MAX];
map <int, int> mp;
int main() {
cin >> n;
for (int i = 1; i <= sqrt(n); i++) {
if (n % i != 0) continue;
v.push_back(i);
if (n / i != i) v.push_back(n / i);
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); i++) {
mp[v[i]] = i + 1;
}
dp[1] = {0};
int id = 0;
for (auto e : v) {
id++;
int id2 = 0;
for (auto e2 : v) {
id2++;
if (id < id2) break;
if (e % e2 != 0) continue;
for (auto e3 : dp[mp[e / e2]]) {
dp[id].push_back(e3 + e2 - 1);
}
}
sort(dp[id].begin(), dp[id].end());
dp[id].erase(unique(dp[id].begin(), dp[id].end()), dp[id].end());
}
cout << dp[v.size()].size() << endl;
for (auto e : dp[v.size()]) {
cout << e << " ";
}
cout << "\n";
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... |