Problem 2891 --2.3.3 Zero Sum1

2891: 2.3.3 Zero Sum1

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $1$ 正确数量 $1$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 usaco 搜索

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. 


PROGRAM NAME: zerosum


A single line with the integer N (3 <= N <= 9). 
In ASCII order, show each sequence that can create 0 sum with a `+', `-', or ` ' between each pair of numbers. 
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

推荐代码 查看2891 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$0 $ms] 计爱玲 448129 2019-07-18 23:23:58
内存最少[$2020 $KB] 计爱玲 448129 2019-07-18 23:23:58
第一AC 计爱玲 448129 2019-07-18 23:23:58
第一挑战 计爱玲 448129 2019-07-18 23:23:58

赛题来源/所属竞赛 usaco training usaco Training

竞赛编号 竞赛名称 竞赛时间 访问比赛