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
Description
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
Sample Output
3
HINT
题意
给你n个数,然后说用一个剪刀把这个序列剪开,要求左边等于右边,问总共有多少种剪开的方法
题解:
统计一个前缀和就好了……
代码
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 2000001
#define mod 1000000007
#define eps 1e-9
int Num;
char CH[];
const int inf=0x3f3f3f3f;
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} //************************************************************************************** int n;
int a[maxn];
int sum[maxn]; int main()
{
int n=read();
for(int i=;i<=n;i++)
a[i]=read(),sum[i]=a[i]+sum[i-];
int ans=;
for(int i=;i<=n-;i++)
{
if(sum[i]==sum[n]-sum[i])
ans++;
}
cout<<ans<<endl;
}
Codeforces Beta Round #18 (Div. 2 Only) C. Stripe 前缀和的更多相关文章
- Codeforces Beta Round #18 (Div. 2 Only)
Codeforces Beta Round #18 (Div. 2 Only) http://codeforces.com/contest/18 A 暴力 #include<bits/stdc+ ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
- Codeforces Beta Round #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
随机推荐
- Selenium RC配置
Selenium RC: -----作者: 虫师 ========================================================================== ...
- 闭包在python中的应用,translate和maketrans方法详解
python对字符串的处理是比较高效的,方法很多.maketrans和translate两个方法被应用的很多,但是具体怎么用常常想不起来. 让我们先回顾下这两个方法吧: 1.s.translate(t ...
- Spring Boot 学习笔记 - 认识Spring Boot框架
因各种原因,.NET前端工程师重新接触JAVA,真是向全栈的路上又迈出了无奈的一步. 下面正文: Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初 ...
- 在mac上搭建python环境
原文出处:http://blog.justbilt.com/2014/07/02/setup_python_on_mac/ 这两天重新搞了下python的环境,发现好多地方还是容易忘记,因此有了这篇文 ...
- Powershell导入订阅号(以Azure中国版为例)
1. 首先,您需要安装Windows Azure Powershell.下载的链接为:http://go.microsoft.com/?linkid=9811175&clcid=0x409 2 ...
- compiled python files
[compiled python files] As an important speed-up of the start-up time for short programs that use a ...
- CF160D
题意:给你一个图,判断每条边是否在最小生成树MST上,不在输出none,如果在所有MST上就输出any,在某些MST上输出at least one: 分析:首先必须知道在最小生成树上的边的权值一定是等 ...
- HDU 4284Travel(状压DP)
HDU 4284 Travel 有N个城市,M条边和H个这个人(PP)必须要去的城市,在每个城市里他都必须要“打工”,打工需要花费Di,可以挣到Ci,每条边有一个花费,现在求PP可不可以从起点1 ...
- How Tomcat Works(三)
上文中描述的简单的服务器是不符合Servlet规范的,所以本文进一步描述一个简单的Servlet容器是怎么实现的 所以我们首先要明白Servlet接口规范,规范有不同版本,本人就先一视同仁了: pub ...
- 解决数据库datatime数据在DataGridView里不显示秒的解决
在数据库中正确显示有分有秒,到dataset里的时候也有,但绑定到DataGridView里的时候就没有秒,解决办法: dataGridView1.Columns["record_time& ...