#include <iostream> using namespace std; const int maxn = 1e4 + 5; int prime[maxn]; bool p[maxn] = {false}; int num = 0; // 获得素数表 void Find_Prime() { for (int i = 2 ; i < maxn ; i++) { if (p[i] == false) { prime[num++] = i; for (int j = i + i ; j < maxn ; j += i) { p[j] = true; } } } } // 双指针(通过首尾指针遍历查找) void Find_n(int n) { int i = 0, j = num - 1; int sum = 0; while(i <= j){ if(prime[i]+prime[j]==n){ sum++; j--; i++; }else if(prime[i]+prime[j]>n){ j--; }else{ i++; } } cout<< sum <<endl; } int main() { int n; Find_Prime(); while (cin >> n) { Find_n(n); } }