-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path108.cpp
More file actions
60 lines (55 loc) · 941 Bytes
/
Copy path108.cpp
File metadata and controls
60 lines (55 loc) · 941 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
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
#include <vector>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <set>
using namespace std;
#define MAX 200000
#define LL long long
#define LIMIT 1000
bool composite[MAX + 1];
vector<int> primes;
void seive(int n)
{
int i, j;
for (i = 2; i * i <= n; i++)
{
if (composite[i])
continue;
for (j = 2 * i; j <= n; j += i)
composite[j] = 1;
primes.push_back(i);
}
for (; i <= n; i++)
if (!composite[i])
primes.push_back(i);
}
int main()
{
seive(MAX);
for (int N = 1000; N < MAX; N++)
{
if (!composite[N])
continue;
// Compute number of divsiors of N squared
int numdiv = 1, cn = N;
for (int i = 0; 1 != cn && i < primes.size(); i++)
{
int count = 0;
while (cn % primes[i] == 0)
{
cn /= primes[i];
count++;
}
numdiv *= (count * 2 + 1);
}
int ans = (numdiv + 1) / 2;
if (ans > LIMIT)
{
cout << N << endl;
break;
}
}
return 0;
}