22148_Primesummation

2022-5-16 18:21| 发布者: Hocassian| 查看: 28| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506150337400-Problem List-采集的数据-后羿采集器.html

Pro.ID

22148

Title

Prime summation

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22148

AC

1

Submit

1

Ratio

100.00%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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
    9 9
    0 0

    Sample Output

    4
    9=5+2+2
    4
    9=3+2+2+2

    Source

    样例输入

    9 2
    9 9
    0 0

    样例输出

    4
    9=5+2+2
    4
    9=3+2+2+2

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部