# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
825315 | alex_2008 | Toys (CEOI18_toy) | C++14 | 5070 ms | 70120 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 <iostream>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
const int NN = 2e3 + 10;
int main() {
int n;
cin >> n;
if (n == 1) {
cout << "1\n";
cout << "0\n";
return 0;
}
vector <int> v;
int j;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) v.push_back(i);
if (i * i < n) j = i;
}
for (int i = j; i >= 1; i--) {
if (n % i == 0) {
v.push_back(n / i);
}
}
unordered_map <int, int> mp, yp;
int N = (int)v.size();
for (int i = 1; i <= (int)v.size(); i++) {
mp[i] = v[i - 1];
yp[v[i - 1]] = i;
}
vector<unordered_set<int>> ans(N + 1);
ans[1] = {0};
for (int i = 1; i < N; i++) {
for (auto it : ans[i]) {
for (int j = 2; j <= N - i + 1; j++) {
if (yp[mp[i] * mp[j]]) {
ans[yp[mp[i] * mp[j]]].insert(it + mp[j] - 1);
}
}
}
}
vector <int> vv(ans[N].begin(), ans[N].end());
sort(vv.begin(), vv.end());
cout << (int)vv.size() << "\n";
for (auto it : vv) {
cout << it << " ";
}
}
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... |