Description

Once Bob took a paper stripe of n squares (the height of the stripe is 1 square). In each square he wrote an integer number, possibly negative. He became interested in how many ways exist to cut this stripe into two pieces so that the sum of numbers from one piece is equal to the sum of numbers from the other piece, and each piece contains positive integer amount of squares. Would you help Bob solve this problem?

Input

The first input line contains integer n (1 ≤ n ≤ 105) — amount of squares in the stripe. The second line contains n space-separated numbers — they are the numbers written in the squares of the stripe. These numbers are integer and do not exceed 10000 in absolute value.

Output

Output the amount of ways to cut the stripe into two non-empty pieces so that the sum of numbers from one piece is equal to the sum of numbers from the other piece. Don't forget that it's allowed to cut the stripe along the squares' borders only.

Sample Input

Input
9
1 5 -6 7 9 -16 0 -2 2
Output
3
Input
3
1 1 1
Output
0
Input
2
0 0
Output
1

题意:
一个序列 有几种划分方法 让 左右两部分相等
代码 很短看看就知道了
#include<iostream>
using namespace std;
long long int x[];
int main(){
int n;
while(cin>>n){
x[]=;
for(int i=;i<=n;i++){
cin>>x[i];
x[i]=x[i]+x[i-];
}
int sum=;
for(int i=;i<=n;i++){
if(x[n]-x[i-]==x[i-])sum++;
}
cout<<sum<<endl;
}
return ;
}

Stripe的更多相关文章

  1. CodeForces 219C Color Stripe

    Color Stripe Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submi ...

  2. Codeforces Beta Round #18 (Div. 2 Only) C. Stripe 前缀和

    C. Stripe Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/18/C ...

  3. 阵列中条带(stripe)、stripe unit

    摘抄:http://blog.sina.com.cn/s/blog_4a362d610100aed2.html 在磁盘阵列中,数据是以条带(stripe)的方式贯穿在磁盘阵列所有硬盘中的.这种数据的分 ...

  4. Codeforces 18C C. Stripe

    Codeforces 18C  C. Stripe 链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/E 题 ...

  5. 1045. Favorite Color Stripe (30) -LCS允许元素重复

    题目如下: Eva is trying to make her own color stripe out of a given one. She would like to keep only her ...

  6. Stripe Compaction

    借鉴于LevelDB.Cassandra的Compaction方法,https://issues.apache.org/jira/browse/HBASE-7667 提出了Stripe Compact ...

  7. 支付-stripe

    国外三大支付paypal,braintree,stripe,有兴趣可以去了解一下他们的区别. 支付宝和paypal基本只需要发送charge信息请求交给后端做就ok了,那么stripe前端也只需要收集 ...

  8. spark SQL读取ORC文件从Driver启动到开始执行Task(或stage)间隔时间太长(计算Partition时间太长)且产出orc单个文件中stripe个数太多问题解决方案

    1.背景: 控制上游文件个数每天7000个,每个文件大小小于256M,50亿条+,orc格式.查看每个文件的stripe个数,500个左右,查询命令:hdfs fsck viewfs://hadoop ...

  9. PAT 甲级 1045 Favorite Color Stripe

    https://pintia.cn/problem-sets/994805342720868352/problems/994805437411475456 Eva is trying to make ...

随机推荐

  1. 20150706 js之定时器

    对应智能社:09 定时器的使用 开启定时器: setInterval(xxx(),1000);//间隔型 第一个参数为函数,第二个为时间,单位为毫秒 setTimeout(xxx(),1000);// ...

  2. ZOJ 2972 Hurdles of 110m 【DP 背包】

    一共有N段过程,每段过程里可以选择 快速跑. 匀速跑 和 慢速跑 对于快速跑会消耗F1 的能量, 慢速跑会集聚F2的能量 选手一开始有M的能量,即能量上限 求通过全程的最短时间 定义DP[i][j] ...

  3. Regionals 2012, Asia - Jakarta 解题报告

    啥都不会做了.. 做题慢死 A.Grandpa's Walk 签到题. 直接DFS就行. 注意先判断这个点可以作为一个路径的起点不. 然后再DFS. 否则处理起来略麻烦 #include <io ...

  4. glog另启动线程写文本日志

    glog本身是很高效的,google的大牛肯定知道大规模的写日志用glog的话肯定会影响业务线程的处理,带负荷的磁盘IO谁都桑不起.比方levelDB就是默认异步写,更不用说google的三驾马车都是 ...

  5. 过渡到SSAS之一:简单模型认识

    本文主要是转载的,但有些地方,原作者没有说的够详细,我加以补充发到这里. --------------------------------------------------------------- ...

  6. Smarty - 安装+入门小例子

    环境: smarty 1.在http://www.smarty.net/download下载最新smarty包,window选择zips,linux下选择tar.gz.以windows为例,下载后解压 ...

  7. EasyUI - tab动态加载datagrid

    addTab: function() { $("#myTabs").tabs('add', { title: 'my title', closable: true, tools: ...

  8. sql server 深入使用 总结 part1

    1   OUTPUT  应用场景 : 1.1.对于INSERT,可以引用inserted表以查询新行的属性.         insert into [表名] (a) OUTPUT Inserted. ...

  9. Android--开发过程中使用到的长度单位

    px:表示屏幕实际的像素. in:表示英寸. mm:毫米. pt:表示一个点,是屏幕的物理尺寸. dp:(与密度无关的像素)逻辑长度单位,在160dpi屏幕上,1dp = 1px = 1/160英寸 ...

  10. OC补充

    OC 1成员变量默认初始化为0 2匿名对象:就是没有名字的对象,比如:(不建议使用) 3 [Car new]->speed = 300; [[Car new] run];(运行结果speed为0 ...