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;
typedef long long lint;
typedef pair<int, int> pii;
const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;
vector<int> ans, D;
int n;
void solve(int x, int m, int sum){
if(m==1){ ans.push_back(sum); return; }
for(int d:D) if(x<=d && m%d==0) solve(d, m/d, sum+d-1);
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n;
for(int i=1; i*i<=n; i++) if(n%i==0) D.push_back(i), D.push_back(n/i);
sort(D.begin(), D.end());
solve(2, n, 0);
sort(ans.begin(), ans.end());
ans.resize(unique(ans.begin(), ans.end())-ans.begin());
cout<<ans.size()<<'\n';
for(int x:ans) cout<<x<<' ';
cout<<'\n';
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... |