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;
#define int long long
#define pii pair<int, int>
int N;
vector<int> factorize(int n){
vector<int> res;
for(int i = 2; i*i<=n;i++){
if(n%i == 0){
res.push_back(i);
if(i*i!=n){
res.push_back(n/i);
}
}
}
res.push_back(n);
return res;
}
map<pii, bool> vis;
unordered_set<int> possib;
void get_sums(int n, int d){
if(n==1){
possib.insert(d);
return;
}
vis[pii(n, d)] = true;
auto factors = factorize(n);
for(auto e: factors){
get_sums(n/e, d+e-1);
}
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>N;
get_sums(N, 0);
vector<int> res;
for(auto e: possib){
res.push_back(e);
}
sort(res.begin(), res.end());
cout<<res.size()<<endl;
for(auto e: res){
cout<<e<<" ";
}
cout<<endl;
}
# | 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... |