# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
823500 | | NK_ | Toys (CEOI18_toy) | C++17 | | 672 ms | 79476 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.
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define pb push_back
#define sz(x) int(x.size())
template<class T> using V = vector<T>;
using vi = V<int>;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N; cin >> N;
if (N == 1) {
cout << 1 << nl;
cout << 0 << nl;
return 0;
}
vi D;
for(int i = 1; i * i <= N; i++) {
if (N % i == 0) {
D.pb(i);
if (i*i != N) D.pb(N / i);
}
}
int M = sz(D);
sort(begin(D), end(D));
V<unordered_set<int>> ans(M);
ans[0].insert(0);
for(int i = 0; i < M; i++) {
for(int j = 0; j < i; j++) {
if (D[i] % D[j] == 0) for(auto& x : ans[j]) ans[i].insert(x + (D[i] / D[j]) - 1);
}
}
vi ANS(begin(ans.back()), end(ans.back()));
sort(begin(ANS), end(ANS));
cout << sz(ANS) << nl;
for(auto& x : ANS) cout << x << " ";
cout << nl;
return 0;
}
# | 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... |