#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()<<'\n';
for(auto j:mp[1])
{
cout<<j<<' ';
}
cout<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |