-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLightOj 1035.cpp
134 lines (94 loc) · 2.1 KB
/
LightOj 1035.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* Which of the favors of your Lord will you deny? */
#include<bits/stdc++.h>
using namespace std;
#define SI(n) scanf("%d",&n)
#define SLL(n) scanf("%lld",&n)
#define SULL(n) scanf("%llu",&n)
#define SC(n) scanf("%c",&n)
#define SD(n) scanf("%lf",&n)
#define fr(i,a,b) for(int i=a ,_b=(b) ;i<= _b;i++)
#define LL long long
#define PUB push_back
#define POB pop_back
#define MP make_pair;
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define GCD __gcd
#define DEBUG cout<<"aw"<<endl;
bool isPrime[110];
vector<int>primes;
void sieve()
{
for(int i=1; i<=100; i++)
isPrime[i]=true;
for(int j=2; j<=100; j++)
{
if(isPrime[j]==true)
{
primes.PUB(j);
for(int k=2; (j*k)<=100; k++)
{
isPrime[j*k]=false;
}
}
}
return;
}
int countPrimefacto[1000];
void porishkar()
{
fr(i,1,100)
countPrimefacto[i]=0;
return;
}
int main()
{
sieve();
int tc;
SI(tc);
fr(i,1,tc)
{
int n;
SI(n);
porishkar();
int track = 1;
for(int q=n;q>1;)
{
for(int j=0;j<primes.size();j++)
{
int x = primes[j];
if(x>q)
break;
while(q%x==0)
{
q = q/x;
countPrimefacto[x]++;
//cout<<"x is "<<x<<endl;
}
}
q = n-track;
track++;
//cout<<"again q is "<<q<<endl;
}
printf("Case %d: %d =",i,n);
int flag;
for(int j=2;j<=100;j++)
{
if(countPrimefacto[j]>0)
{
printf(" %d (%d)",j,countPrimefacto[j]);
flag = j;
break;
}
}
for(int j=flag+1;j<=100;j++)
{
if(countPrimefacto[j]>0)
{
printf(" * %d (%d)",j,countPrimefacto[j]);
}
}
printf("\n");
}
return 0;
}