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;
int n,m,k;
vector<int>ans;
vector<int>di;
unordered_map<int,map<int,bool>>vis;
int sum = 0;
void dfs(int x){
vis[x][sum] = 1;
if(x == 1){
ans.push_back(sum);
return;
}
int to = x;
if(x % to == 0 && vis[x/to][sum+to-1] == 0){
sum = sum + to - 1;
dfs(x/to);
sum = sum - to + 1;
}
for(to = 2; to*to <= x;to++){
if(x % to == 0 && vis[x/to][sum+to-1] == 0){
sum = sum + to - 1;
dfs(x/to);
sum = sum - to + 1;
}
}
}
void solve(){
cin >> n;
dfs(n);
sort(ans.begin(),ans.end());
cout<<ans.size()<<"\n";
for(auto to:ans)cout << to << " ";
}
/*
*/
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int tt=1;//cin>>tt>>n;
while(tt--)solve();
}
# | 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... |