题解:
打表+判断
import java.util.*;
public class Main {
static List<Integer> prime = new ArrayList<>();
static int[] vis = new int[1001];
static int cnt = 0;
//素数表
static void init() {
for (int i = 2; i <= 1000; i++) {
if (vis[i] == 0) {
prime.add(Integer.valueOf(i));
for (int j = i; j <= 1000; j += i)
vis[j] = 1;
}
}
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int n, ans = 0;
init();
n = cin.nextInt();
for (int i = 0; i < prime.size() && prime.get(i) <= n - prime.get(i); i++) {
if (prime.contains(n - prime.get(i))) {
ans++;
}
}
System.out.println(ans);
}
}