#include #define INF 2147483647 #define INF_LL 9223372036854775807 #define MOD 1000000007 using namespace std; typedef long long int ll; typedef unsigned long long int ull; class eratosthenes { public: vector prime_n; bool prime[500001]; eratosthenes() { fill(prime, prime + 500001, true); //素数 prime[0] = prime[1] = false; for (int i = 2; i < 500001; i++) { if (prime[i] == true) { prime_n.push_back(i); for (int j = 2; i * j < 500001; j++) { prime[i * j] = false; } } } } }; int main() { eratosthenes p; int N, ans = 0; cin >> N; for (int i = 0; i < p.prime_n.size() && p.prime_n[i] <= N; i++) { for (int j = 0; j < p.prime_n.size() && p.prime_n[j] <= N; j++) { int r = p.prime_n[j] + p.prime_n[i], r_ = floor(sqrt(r)); if (r == r_*r_ && p.prime[r_]) { ans++; } } } cout << ans << endl; }