22861_Combinations

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

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

Pro.ID

22861

Title

Combinations

Title链接

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

AC

70

Submit

219

Ratio

31.96%

时间&空间限制

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

    To unlock a combination lock you must rotate a dial alternately right and left through a sequence of positive numbers.  For this problem, a sequence (C1, C2, ..., Cn) is called a combination for M if it has the following properties:

    1) n > 1

    2) Ci - Ci-1 = 1 for all i

    3) C1 + C2 + ...... Cn = M

    Create a program which will find all possible combinations for a given M.  Express each combination by giving the first and last number in the combination.

    Example: 1998 2002 denotes the following combination for M=10,000:

    1998+1999+2000+2001+2002 = 10000

    输入

    A single line with the integer M (10 ≤ M ≤ 2,000,000).

    输出

    Description

    To unlock a combination lock you must rotate a dial alternately right and left through a sequence of positive numbers.  For this problem, a sequence (C1, C2, ..., Cn) is called a combination for M if it has the following properties:

    1) n > 1

    2) Ci - Ci-1 = 1 for all i

    3) C1 + C2 + ...... Cn = M

    Create a program which will find all possible combinations for a given M.  Express each combination by giving the first and last number in the combination.

    Example: 1998 2002 denotes the following combination for M=10,000:

    1998+1999+2000+2001+2002 = 10000

    Input

    A single line with the integer M (10 ≤ M ≤ 2,000,000).

    Output

    A set of lines with two numbers as described above.  Order the lines by increasing first number (with ties broken by consulting the second number). It is guaranteed that at least one answer exists.

    Sample Input

    10000

    Sample Output

    18 142
    297 328
    388 412
    1998 2002

    Source

    样例输入

    10000

    样例输出

    18 142
    297 328
    388 412
    1998 2002

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部