Pro.ID22861 TitleCombinations Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22861 AC70 Submit219 Ratio31.96% 时间&空间限制描述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 Source 样例输入10000 样例输出18 142 作者 |