Stripe
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
9
1 5 -6 7 9 -16 0 -2 2
3
3
1 1 1
0
2
0 0
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的更多相关文章
- CodeForces 219C Color Stripe
Color Stripe Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submi ...
- 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 ...
- 阵列中条带(stripe)、stripe unit
摘抄:http://blog.sina.com.cn/s/blog_4a362d610100aed2.html 在磁盘阵列中,数据是以条带(stripe)的方式贯穿在磁盘阵列所有硬盘中的.这种数据的分 ...
- Codeforces 18C C. Stripe
Codeforces 18C C. Stripe 链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=86640#problem/E 题 ...
- 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 ...
- Stripe Compaction
借鉴于LevelDB.Cassandra的Compaction方法,https://issues.apache.org/jira/browse/HBASE-7667 提出了Stripe Compact ...
- 支付-stripe
国外三大支付paypal,braintree,stripe,有兴趣可以去了解一下他们的区别. 支付宝和paypal基本只需要发送charge信息请求交给后端做就ok了,那么stripe前端也只需要收集 ...
- spark SQL读取ORC文件从Driver启动到开始执行Task(或stage)间隔时间太长(计算Partition时间太长)且产出orc单个文件中stripe个数太多问题解决方案
1.背景: 控制上游文件个数每天7000个,每个文件大小小于256M,50亿条+,orc格式.查看每个文件的stripe个数,500个左右,查询命令:hdfs fsck viewfs://hadoop ...
- PAT 甲级 1045 Favorite Color Stripe
https://pintia.cn/problem-sets/994805342720868352/problems/994805437411475456 Eva is trying to make ...
随机推荐
- ADO.NET 总结
一.简单介绍ADO.NET System.Data:DataTable,DataSet,DataRow,DataColumn,DataRelation,Constraint System.Data.C ...
- Linux 下github的使用
*初始化git仓库,使用git init命令 *添加文件到git仓库分两步: 1.使用git add filename :可分多次使用,添加多个文件到暂存区 2.使用git commit -m “ ...
- perl 执行mysql select 返回多条记录
[root@dr-mysql01 sbin]# cat t1.pl use DBI; my $dbUser='DEVOPS'; my $user="root"; my $passw ...
- commoncrawl 源码库是用于 Hadoop 的自定义 InputFormat 配送实现
commoncrawl 源码库是用于 Hadoop 的自定义 InputFormat 配送实现. Common Crawl 提供一个示例程序 BasicArcFileReaderSample.java ...
- 下载并在Eclipse中关联Android源代码
大家都知道文档写的好当然让人非常舒服,可是有时候文档再好也不如直接看源代码来的直接,既然Android是开源的,为什么不在eclipse里直接看它的源代码呢? 1.下载源代码 这部分网上有大量的资料, ...
- test code
<?php abstract class Mediator{ abstract public function send($message, $colleague); } abstract cl ...
- BZOJ 4057: [Cerc2012]Kingdoms( 状压dp )
状压dp.... 我已开始用递归结果就 TLE 了... 不科学啊...我dp基本上都是用递归的..我只好改成递推 , 刷表法 将全部公司用二进制表示 , 压成一个数 . 0 表示破产 , 1 表示没 ...
- 【转】Lua脚本语法说明简介
Lua 的语法比较简单,学习起来也比较省力,但功能却并不弱. 所以,我只简单的归纳一下Lua的一些语法规则,使用起来方便好查就可以了.估计看完了,就懂得怎么写Lua程序了. 在Lua中,一切都是变量, ...
- Python 第五篇(下):系统标准模块(shutil、logging、shelve、configparser、subprocess、xml、yaml、自定义模块)
目录: shutil logging模块 shelve configparser subprocess xml处理 yaml处理 自定义模块 一,系统标准模块: 1.shutil:是一种高层次的文件操 ...
- python pyfits
原链接:http://blog.sina.com.cn/s/blog_a046022d0101a48h.html,全文复制以备出错. 导入pyfits模块:import pyfits ...