# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
975330 | IBory | Toys (CEOI18_toy) | C++17 | 5034 ms | 117432 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>
#include <unordered_set>
using namespace std;
const int MAX = 222222;
vector<int> D;
unordered_set<int> S[MAX];
int main() {
int N;
cin >> N;
for (int i = 1; i * i <= N; ++i) {
D.push_back(i);
if (i * i != N) D.push_back(N / i);
}
sort(D.begin(), D.end());
S[0].insert(0);
for (int i = 0; i < D.size(); ++i) {
// sort(S[i].begin(), S[i].end());
// S[i].erase(unique(S[i].begin(), S[i].end()), S[i].end());
for (int j = i + 1; j < D.size(); ++j) {
if (D[j] % D[i]) continue;
for (int n : S[i]) S[j].insert(n + D[j] / D[i] - 1);
}
}
vector<int> ans;
for (int n : S[D.size() - 1]) ans.push_back(n);
sort(ans.begin(), ans.end());
cout << ans.size() << '\n';
for (int n : ans) cout << n << ' ';
return 0;
cout << S[D.size() - 1].size() << '\n';
for (int n : S[D.size() - 1]) 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... |