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;
#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif
const int N = 10005;
bool dp[20][N][N];
int n;
vector<int> ans;
void bt (int sz, int s = 1, int sum = 0) {
if (sz >= 20 || s >= N || sum >= N) {
cout << "b";
exit(0);
}
bool& ret = dp[sz][s][sum];
if (ret) return;
ret = true;
if (sz == 0) {
if (s == n) {
ans.push_back(sum);
return;
}
return;
}
for (int i = 1; i < n; ++i) {
if (s * (i + 1) > n) break;
bt(sz - 1, s * (i + 1), sum + i);
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 0; (1 << i) <= n; ++i) {
bt(i);
}
sort(ans.begin(), ans.end());
ans.resize(unique(ans.begin(), ans.end()) - ans.begin());
cout << (int) ans.size() << '\n';
for (int i : ans) cout << i << ' ';
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... |