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 <map>
#include <set>
#include <bitset>
#include <algorithm>
#include <queue>
using namespace std;
const int N=1e9+1;
bitset<N> vis;
map<int,vector<int>> mp;
priority_queue<int> q;
int main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int n;
cin>>n;
q.push(n);
vis[n]=1;
mp[n]={0};
while(q.size())
{
int f=q.top();
q.pop();
sort(begin(mp[f]),end(mp[f]));
mp[f].resize(unique(begin(mp[f]),end(mp[f]))-begin(mp[f]));
for(int j=2;(j*j)<=f;j++)
{
if(f%j==0)
{
if(!vis[f/j])
{
vis[f/j]=1;
q.push(f/j);
}
if(!vis[j])
{
vis[j]=1;
q.push(j);
}
for(auto&kp:mp[f])
mp[(f/j)].push_back(kp+(j-1));
if((f)!=(j*j))
{
for(auto&kp:mp[f])
mp[j].push_back(kp+((f/j)-1));
}
}
}
for(auto&kp:mp[f])
mp[1].push_back(kp+(f-1));
}
cout<<mp[1].size()<<endl;
for(auto j:mp[1])
{
cout<<j<<' ';
}
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... |