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 <queue>
using namespace std;
const int N=1e9+1;
bitset<N> vis;
map<int,set<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();
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)].insert(kp+(j-1));
if((f)!=(j*j))
{
for(auto&kp:mp[f])
mp[j].insert(kp+((f/j)-1));
}
}
}
for(auto&kp:mp[f])
mp[1].insert(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... |