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;
//DSU
set<int> ans;
void sum(int x,int su,int last){
if(x==1){
ans.insert(su);
return;
}
for(long long i = 1;i*i<=x;i++){
if(x%i==0){
if(i!=1&&i>=last)sum(x/i , su+(i-1) , i);
if(x/i!=i){
if(x/i>=last)sum(x/(x/i) , su+((x/i)-1) , x/i);
}
}
}
}
int main(){
//freopen("poklonin6.txt","r",stdin);
long long n;
cin>>n;
sum(n,0,0);
cout<<ans.size()<<"\n";
for(auto i:ans)cout<<i<<" ";
}
# | 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... |