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 <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#pragma GCC optimize("O3")
int n;
vector<int> st;
void solve(int n, int s, int j) {
if (n == 1) {
st.push_back(s);
return;
}
for (int i=1; i*i<=n; ++i) {
if (n%i != 0) continue;
if (i >= j) solve(n/i, s+i-1, i);
if (n/i >= j) solve(i, s+n/i-1, n/i);
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin>>n;
solve(n, 0, 2);
sort(st.begin(), st.end());
st.erase(unique(st.begin(), st.end()), st.end());
cout<<st.size()<<"\n";
for (auto u : st) cout<<u<<" ";
cout<<"\n";
}
# | 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... |