#P17455. [GESP202609 五级] 哥德巴赫猜想

    ID: 19984 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及− 上传者: 标签>数论枚举素数判断2026GESP

[GESP202609 五级] 哥德巴赫猜想

Problem Description

As everyone knows, Goldbach's conjecture says that any even number greater than 22 can be written as the sum of two prime numbers. For example:

  • 4=2+24=2+2
  • 6=3+36=3+3
  • 8=3+58=3+5
  • 10=3+7=5+510=3+7=5+5

You surely want to know: for an even number nn greater than 22, how many ways are there to write it as the sum of two primes? For example, 44, 66, and 88 each have only one way, while 1010 has two ways. Please write a program to compute the answer.

In this problem, we consider two representations different if and only if the sets of primes used in the two representations are different. That is, 10=3+710=3+7 and 10=7+310=7+3 are the same representation and must not be counted twice.

Input Format

One line containing an even integer nn greater than 22.

Output Format

One line containing an integer, representing the number of ways to write nn as the sum of two primes.

4
1
10
2

Hint

For 40%40\% of the test points, 4≤n≤1004 \le n \le 100 is guaranteed.

For all test points, 4≤n≤1064 \le n \le 10^6 is guaranteed.

Translated by ChatGPT 5