-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuva160.cpp
58 lines (46 loc) · 1.4 KB
/
uva160.cpp
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using namespace std;
#include<iostream>
#include<cstdio>
int main()
{
int ans[30],n,N,temp,i,j,count;
int prime [] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
while(scanf("%d",&N)&&N)
{
for(i=0;i<25;i++)
ans[i]=0;
n=N;
while(n>1)
{
i=0;
temp=n;
while(temp>1)
{
count=0;
while(temp%prime[i]==0)
{
count++;
temp/=prime[i];
}
ans[i]+=count;
i++;
}
n--;
}
for(i=24;i>=0;i--)
{
if(ans[i]>0)
break;
}
printf("%3d! =",N);
//printf("%6c",' ');
for(j=0;j<=i;j++)
{
if(j==15)
printf("\n%6c",' ');
printf("%3d", ans[j]);
}
printf("\n");
}
return 0;
}