21997_Desser

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

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

Pro.ID

21997

Title

Dessert

Title链接

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

AC

12

Submit

30

Ratio

40.00%

时间&空间限制

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

    FJ has a new rule about the cows lining up for dinner. Not only must the N (3 ≤ N ≤ 15) cows line up for dinner in order, but they must place a napkin between each pair of cows with a "+", "-", or "." on it. In order to earn their dessert, the cow numbers and the napkins must form a numerical expression that evaluates to 0. The napkin with a "." enables the cows to build bigger numbers. Consider this equation for seven cows:

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

    This means 1-23-45+67, which evaluates to 0. You job is to assist the cows in getting dessert. (Note: "... 10 . 11 ...") will use the number 1011 in its calculation.)

    输入

    One line with a single integer, N

    输出

    Description

    FJ has a new rule about the cows lining up for dinner. Not only must the N (3 ≤ N ≤ 15) cows line up for dinner in order, but they must place a napkin between each pair of cows with a "+", "-", or "." on it. In order to earn their dessert, the cow numbers and the napkins must form a numerical expression that evaluates to 0. The napkin with a "." enables the cows to build bigger numbers. Consider this equation for seven cows:

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

    This means 1-23-45+67, which evaluates to 0. You job is to assist the cows in getting dessert. (Note: "... 10 . 11 ...") will use the number 1011 in its calculation.)

    Input

    One line with a single integer, N

    Output

    One line of output for each of the first 20 possible expressions -- then a line with a single integer that is the total number of possible answers. Each expression line has the general format of number, space, napkin, space, number, space, napkin, etc. etc. The output order is lexicographic, with "+" coming before "-" coming before ".". If fewer than 20 expressions can be formed, print all of the expressions.

    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
    6

    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
    6

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部