-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrailing Zeroes (I).cpp
64 lines (57 loc) · 1021 Bytes
/
Trailing Zeroes (I).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
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int maxN = 1000001;
vector <int> prime;
bool ok[maxN+10];
void sieve()
{
memset(ok,true,sizeof(ok));
for(int i = 3;i*i<=maxN;i+=2)
{
if(ok[i])
{
for(int j = i*i;j<=maxN;j+=i+i)
{
ok[j] = false;
}
}
}
prime.push_back(2);
for(int i = 3;i<=maxN;i+=2)
{
if(ok[i])
{
prime.push_back(i);
}
}
}
int NOD(int n)
{
int cnt = 0,pro = 1;
for(int p : prime)
{
cnt = 0;
if(p*p>n) break;
while(n%p == 0)
{
cnt++;
n/=p;
}
pro *= (cnt+1);
}
if(n > 1) pro *= 2;
return pro;
}
int main()
{
sieve();
int t,n,cnt = 1;
cin >> t;
while(t--)
{
cin >> n;
cout << "Case " << cnt++ << ": " << NOD(n) - 1 << "\n";
}
return 0;
}