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 <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
map<int,int> num;
signed main(){
int n;
cin>>n;
vector<int> d;
for (int i=1;i * i<=n;i++){
if (n % i == 0){
d.push_back(i);
d.push_back(n / i);
}
}
sort(begin(d),end(d));
set<int> S[d.size() + 100];
S[0].insert(0);
int k = d.size();
for (int i=0;i<k;i++)
num[d[i]] = i+1;
set<pair<int,int>> P;
P.insert({0,1});
for (int i=1;i<k;i++){
S[i].insert(d[i]-1);
for (auto [l,j] : P){
if (j * d[i] > n)
continue;
for (int m : S[i]){
P.insert({l + m,j * d[i]});
if (j * d[i] == n)
S[k-1].insert(l + m);
}
}
}
cout<<S[k-1].size()<<'\n';
for (int i : S[k-1])
printf("%d ",i);
printf("\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... |