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 ...
随机推荐
- CentOS 6.4安装(超级详细图解教程)
链接地址:http://www.osyunwei.com/archives/5855.html CentOS 6.4安装(超级详细图解教程) 附:CentOS 6.4下载地址 32位:http://m ...
- Google Code Jam Round 1A 2015 Problem B. Haircut 二分
Problem You are waiting in a long line to get a haircut at a trendy barber shop. The shop has B barb ...
- linux c coding style
Linux kernel coding style This is a short document describing the preferred coding style for the lin ...
- UVA 10763 Foreign Exchange 出国交换 pair+map
题意:给出很多对数字,看看每一对(a,b)能不能找到对应的(b,a). 放在贪心这其实有点像检索. 用stl做,map+pair. 记录每一对出现的次数,然后遍历看看对应的那一对出现的次数有没有和自己 ...
- Android中如何查看内存(下)
实例1 int cnt=0; final static int kBufferMinSize=1000; final static int kBufferMaxSize=2000; StringBuf ...
- jquery分页
//分页插件 /** 2015-12-7 **/ (function($){ var ms = { init:function(obj,args){ return (function(){ ms.fi ...
- 常见的transformation 和 Action
常见transformation map 将RDD中的每个元素传入自定义函数,获取一个新的元素,然后用新的元素组成新的RDD filter 对RDD中每个元素进行判断,如果返回true则保留,返回fa ...
- Android项目实战手机安全卫士(02)
目录 项目结构图 源代码 运行结果 项目源代码 项目结构图 源代码 清单 01. SplashActivity.java package com.coderdream.mobilesafe.acti ...
- 有关oppo蝴蝶解锁的三D技术
oppo手机的界面设计也是很漂亮的.在很多界面中使用了3D技术塑造出了大量华丽的效果.在蝴蝶解锁中使用了两个对称的三D变幻,宛如蝴蝶翅膀上美丽的花纹.在受到用户点击后,随风缓慢上下扇动,充满浪漫的动感 ...
- android Context的理解
很多初入Android开发的网友向我们问到Context有什么作用,很多地方都用到它,这里Android123给这些新入门的网友做个简单的解释: Context字面意思上下文,位于framework ...