-
Notifications
You must be signed in to change notification settings - Fork 0
/
turkiye.cpp
64 lines (51 loc) · 1.28 KB
/
turkiye.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 <iostream>
#include <array>
#include <cmath>
#define PRIME_COUNT 1000
constexpr std::array<long long, PRIME_COUNT> calculatePrimes(long long max)
{
std::array<long long, PRIME_COUNT> primes {};
long long primeCount = 0;
std::array<bool, 100000> isPrime {};
for (long long i = 0; i < max; i++)
{
isPrime[i] = true;
}
isPrime[0] = isPrime[1] = false;
for (long long i = 2; i < max; i++)
{
if (isPrime[i])
{
primes[primeCount++] = i;
for (long long j = i*i; j < max; j += i)
{
isPrime[j] = false;
}
}
}
return primes;
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(NULL);
long long N;
std::cin >> N;
constexpr long long maxPrime = 100000;
std::array<long long, PRIME_COUNT> primes = calculatePrimes(maxPrime+1);
long long result = 0;
for (long long q : primes)
{
long long q5 = q * q * q * q * q;
if (q5 > N)
break;
long long p = 1;
while (q5 * p <= N && p <= q)
{
// std::cout << q5 << " " << p << std::endl;
result++;
p++;
}
}
std::cout << result << std::endl;
return 0;
}