-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathFACTCG2.cpp
More file actions
27 lines (26 loc) · 866 Bytes
/
FACTCG2.cpp
File metadata and controls
27 lines (26 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<stdio.h>
#define max 10000007
int a[max]={0};
void sieve(){
for(int i=2;i<=max;i++){
if(a[i]!=0)continue;
for(int j=2*i;j<=max;j+=i){
if(a[j]==0)
a[j]=i;
}
}
}
int main(){
int n;
sieve();
//printf("%d %d",a[1000007],a[6]);
while(scanf("%d",&n)!=EOF){
if(n==1){printf("%d\n",n);continue;}
else printf("1");
if(a[n]!=0)
while(n%a[n]==0){printf(" x %d",a[n]);if(a[n]==0)break;n/=a[n];if(a[n]==0)break;}
printf(" x %d",n);
printf("\n");
}
return 0;
}