Pro.ID10141 TitleZero Sum Title链接http://10.20.2.8/oj/exercise/problem?problem_id=10141 AC65 Submit165 Ratio39.39% 时间&空间限制描述Consider the sequence of digits from 1 through N (where N=9) in increasing order: 1 2 3 ... N. Now insert either a '+' for addition or a '-' for subtraction or a ' ' [blank] to run the digits together between each pair of digits (not in front of the first digit). Calculate the result that of the expression and see if you get zero. Write a program that will find all sequences of length N that produce a zero sum. 输入Multiple test cases. Each case contains a single line with the integer N ( 3 ≤ N ≤ 9 ). 输出Description Consider the sequence of digits from 1 through N (where N=9) in increasing order: 1 2 3 ... N. Now insert either a '+' for addition or a '-' for subtraction or a ' ' [blank] to run the digits together between each pair of digits (not in front of the first digit). Calculate the result that of the expression and see if you get zero. Write a program that will find all sequences of length N that produce a zero sum. Input Multiple test cases. Each case contains a single line with the integer N ( 3 ≤ N ≤ 9 ). Output For each case, in ASCII order, show each sequence that can create 0 sum with a '+', '-', or ' ' between each pair of numbers. Output a blank line after each case. Sample Input 7 Sample Output 1+2-3+4-5-6+7 Source 样例输入7 样例输出1+2-3+4-5-6+7 作者 |