#include <bits/stdc++.h>
using namespace std;
signed main(){
int n; cin >> n;
if ( n == 1 ) return cout << "1\n0\n", 0;
vector <int> d{n};
for ( int i = 2; i * i <= n; i++ ){
if ( n % i == 0 ){
d.push_back(i);
if ( i * i != n ) d.push_back(n / i);
}
}
sort(d.begin(), d.end());
set <int> st;
auto dfs = [&](auto dfs, int x, int s, int i) -> void{
if ( x == 1 ){
st.insert(s);
return;
}
while ( i >= 0 && x % d[i] ) i--;
if ( i < 0 ) return;
dfs(dfs, x / d[i], s + d[i] - 1, i);
dfs(dfs, x, s, i - 1);
};
dfs(dfs, n, 0, d.size() - 1);
cout << st.size() << '\n';
for ( auto &x: st ) cout << x << ' ';
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... |