10141_ZeroSu

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

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

Pro.ID

10141

Title

Zero Sum

Title链接

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

AC

65

Submit

165

Ratio

39.39%

时间&空间限制

  • Time Limit: 200/100 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others)
  • 描述

    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
    1+2-3-4+5+6-7
    1-2 3+4+5+6+7
    1-2 3-4 5+6 7
    1-2+3+4-5+6-7
    1-2-3-4-5+6+7

    Source

    样例输入

    7

    样例输出

    1+2-3+4-5-6+7
    1+2-3-4+5+6-7
    1-2 3+4+5+6+7
    1-2 3-4 5+6 7
    1-2+3+4-5+6-7
    1-2-3-4-5+6+7

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部