#include<bits/stdc++.h>
#define N 1000000
#define ll long long int
using namespace std;
int p[N+1];
void seive()
{
ll i, j;
for(i=1; i<=N; i++)
p[i] = i;
for(i=4; i<=N; i+=2)
p[i] = 2;
for(i=3; i*i<=N; i++)
{
if(p[i] == i)
{
for(j=i*i; j<=N; j+=i)
if(p[j] == j)
p[j] = i;
}
}
}
vector<int> getfactor(ll n)
{
vector<int>r;
while(n != 1)
{
r.push_back(p[n]);
n = n/p[n];
}
return r;
}
int main()
{
seive();
ll n, i;
cin >> n;
vector<int>c = getfactor(n);
for(i=0;i<c.size();i++)
cout << c[i] << " ";
return 0;
}
#define N 1000000
#define ll long long int
using namespace std;
int p[N+1];
void seive()
{
ll i, j;
for(i=1; i<=N; i++)
p[i] = i;
for(i=4; i<=N; i+=2)
p[i] = 2;
for(i=3; i*i<=N; i++)
{
if(p[i] == i)
{
for(j=i*i; j<=N; j+=i)
if(p[j] == j)
p[j] = i;
}
}
}
vector<int> getfactor(ll n)
{
vector<int>r;
while(n != 1)
{
r.push_back(p[n]);
n = n/p[n];
}
return r;
}
int main()
{
seive();
ll n, i;
cin >> n;
vector<int>c = getfactor(n);
for(i=0;i<c.size();i++)
cout << c[i] << " ";
return 0;
}
Comments
Post a Comment