Pro.ID22148 TitlePrime summation Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22148 AC1 Submit1 Ratio100.00% 时间&空间限制描述Any number greater than 1 can be expressed as sum of some primes, and there may be many ways. For example, the number 9 can be expressed in 4 ways, 9 = 7+2 = 5+2+2 = 3+3+3 = 3+2+2+2. We order the summations in this way: we order the summations according the first summand in decreasing order. If in a tie, we order them according the second summand in decreasing order, etc. Now, in this problem, you are given two number N and K. Your job is to find the total ways to express N as some primes, and the K-th summations to express N. 输入Input contains two numbers N and K as described above. 2 ≤ N ≤ 200, 1 ≤ K ≤ 109. Input is ended by N=K=0, which should not be processed. 输出Description Any number greater than 1 can be expressed as sum of some primes, and there may be many ways. For example, the number 9 can be expressed in 4 ways, 9 = 7+2 = 5+2+2 = 3+3+3 = 3+2+2+2. We order the summations in this way: we order the summations according the first summand in decreasing order. If in a tie, we order them according the second summand in decreasing order, etc. Now, in this problem, you are given two number N and K. Your job is to find the total ways to express N as some primes, and the K-th summations to express N. Input Input contains two numbers N and K as described above. 2 ≤ N ≤ 200, 1 ≤ K ≤ 109. Input is ended by N=K=0, which should not be processed. Output First output the total ways in the first line. Then in the second line output the K-th summation in the format like this: 9=3+3+3. If K > the total ways just output the last summation. Sample Input 9 2 Sample Output 4 Source 样例输入9 2 样例输出4 作者 |