#P1832. A+B Problem(再升级)

    ID: 785 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>动态规划,dp数学递推洛谷原创背包素数判断,质数,筛法

A+B Problem(再升级)

Description

  • 1+1=?1+1=? Obviously 22.
  • a+b=?a+b=? See P1001, don't thank me.
  • Goldbach's conjecture seems to be everywhere.

The above is purely a personal rant.

Given a positive integer nn, find the total number of ways to express it as a sum of prime numbers. The order of addends does not matter.

Input Format

One line containing a positive integer nn.

Output Format

One line containing an integer representing the total number of ways.

7
3
20
26

Hint

Sample Explanation

There are the following three ways:

  • 7=77=7.
  • 7=2+57=2+5.
  • 7=2+2+37=2+2+3.

Constraints

  • For 30%30\% of the testdata, 1n101 \le n \le 10.
  • For 100%100\% of the testdata, 1n1031 \le n \le 10^3.

Translated by ChatGPT 5