-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy path10699.cpp
executable file
·51 lines (44 loc) · 1 KB
/
10699.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
/* Problem: Problem D - Count the factors UVa 10699
Programmer: Md. Mahmud Ahsan
Compiled: Visual C++ 6.0
Date: 15-04-05
*/
#include <iostream>
#include <cmath>
using namespace std;
#define sqRoot sqrt( (double) 1000000)
long seive[1000000];
long prmCol[1000000];
void genSeive();
//======================================
int main(){
genSeive();
long orginal, input, i;
int prmFactor;
while (cin >> input && input != 0){
orginal = input;
prmFactor = 0;
for (i = 0; i <= 1000000 && prmCol[i] != 0; ++i){
if ( input % prmCol[i] == 0){
input = input / prmCol[i];
++prmFactor;
}
}
cout << orginal << " : " << prmFactor << endl;
}
return 0;
}
//==========================================================
void genSeive(){
long i, j;
seive[0]=seive[1] = 1;
for (i = 2; i <= sqRoot; ++i){
for (j = i + i; j < 1000000; j += i)
seive[j] = 1;
}
j = -1;
for (i = 2; i < 1000000; ++i){
if (seive[i] == 0)
prmCol[++j] = i;
}
}