#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>
using namespace std;
bitset<46342> p;
vector<long long> prime;
void calc(){
long long tmp=sqrt(46342);
for(long long i=2;i<46342;i++){
if(!p[i]){
prime.push_back(i);
if(i<=tmp)
for(long long j=i*i;j<46342;j+=i)
p[j]=1;
}
}
}
int main(){
ios::sync_with_stdio(0);
calc();
long long n;
while(cin>>n&&n){
cout<<n<<" = ";
long long beg=1;
if(n<0)
cout<<-1,beg=0,n*=-1;
for(long long i=0;i<=sqrt(n)&&i<prime.size();){
if(n%prime[i]==0){
if(beg)
cout<<prime[i],beg=0;
else
cout<<" x "<<prime[i];
n/=prime[i];
}
else
i++;
}
if(n>1)
if(beg)
cout<<n;
else
cout<<" x "<<n;
cout<<endl;
}
}
#include <vector>
#include <bitset>
#include <cmath>
using namespace std;
bitset<46342> p;
vector<long long> prime;
void calc(){
long long tmp=sqrt(46342);
for(long long i=2;i<46342;i++){
if(!p[i]){
prime.push_back(i);
if(i<=tmp)
for(long long j=i*i;j<46342;j+=i)
p[j]=1;
}
}
}
int main(){
ios::sync_with_stdio(0);
calc();
long long n;
while(cin>>n&&n){
cout<<n<<" = ";
long long beg=1;
if(n<0)
cout<<-1,beg=0,n*=-1;
for(long long i=0;i<=sqrt(n)&&i<prime.size();){
if(n%prime[i]==0){
if(beg)
cout<<prime[i],beg=0;
else
cout<<" x "<<prime[i];
n/=prime[i];
}
else
i++;
}
if(n>1)
if(beg)
cout<<n;
else
cout<<" x "<<n;
cout<<endl;
}
}
Comments
Post a Comment