YTU 2902: H-Sum 3s
2902: H-Sum 3s
时间限制: 1 Sec 内存限制: 128 MB
提交: 139 解决: 28
题目描述
输入
Input consists of multiple test cases. For each case, the first line of input contains an integer n, the next line follows n integers. (n>=1 && n<=10^5 |ai|<=10^4)
输出
样例输入
51 2 3 4 553 4 -2 -3 1
样例输出
NOYES
im0qianqian_站在回忆的河边看着摇晃的渡船终年无声地摆渡,它们就这样安静地画下黄昏画下清晨......
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int N;
while (cin>>N)
{
int i,k=0,a[100000],s[100000];
cin>>a[0];
s[0]=a[0];
if (a[0]==0)
k=1;
for (i=1; i<N; i++)
{
cin>>a[i];
s[i]=s[i-1]+a[i];
if (a[i]==0||s[i]==0)
k=1;
}
if (k==0)
{
sort(s,s+N);
for (i=0; i<N-1; i++)
if (s[i]==s[i+1])
{
k=1;
break;
}
}
if (k==1)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl; }
return 0;
}
YTU 2902: H-Sum 3s的更多相关文章
- YTU 2905: The Sum of 1...N
2905: The Sum of 1...N 时间限制: 1 Sec 内存限制: 128 MB 提交: 281 解决: 51 题目描述 Given an integer n,your task i ...
- URAL 1146 Maximum Sum 最大子矩阵和
题目:click here #include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; con ...
- Uva10290 - {Sum+=i++} to Reach N
Problem H {sum+=i++} to Reach N Input: standard input Output: standard output Memory Limit: 32 MB A ...
- [leetcode-560-Subarray Sum Equals K]
Given an array of integers and an integer k, you need to find the total number of continuous subarra ...
- 给定n个数字,问能否使这些数字相加得到h【折半查找/DFS】
A Math game Time Limit: 2000/1000MS (Java/Others) Memory Limit: 256000/128000KB (Java/Others) Submit ...
- PAT 1049. 数列的片段和(20)
给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段.例如,给定数列{0.1, 0.2, 0.3, 0.4},我们有(0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1 ...
- Mysql 常用 SQL 语句集锦
Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...
- POJ 3233Matrix Power Series
妈妈呀....这简直是目前死得最惨的一次. 贴题目: http://poj.org/problem?id=3233 Matrix Power Series Time Limit: 3000MS Mem ...
- Gym 100703I---Endeavor for perfection(尺取)
题目链接 http://codeforces.com/problemset/gymProblem/100703/I Description standard input/outputStatement ...
随机推荐
- spring的IOC和DI
https://blog.csdn.net/fuzhongmin05/article/details/55802816 (1)IOC:控制反转,把对象创建交给spring进行配置 (2)DI:依赖注入 ...
- 如何安装python包
安装python包有两种方法: 使用Python包管理器pip工具 在Linux系统中,首先 yum install python-pip 然后就可以欢快的pip install *** 啦 源代码安 ...
- 【课余作品】简约QQ申请器(永久免费更新)
UPDATEDATE:2013-08-28 下载地址:http://pan.baidu.com/share/link?shareid=3376000151&uk=3339155803
- Food Delivery (区间DP)
When we are focusing on solving problems, we usually prefer to stay in front of computers rather tha ...
- B题 Sort the Array
题目大意:判断能否通过一次倒置,使序列变为一个递增序列 如果可以,输出倒置那一段的起始点和终点的位置: 题目链接:http://codeforces.com/problemset/problem/45 ...
- POJ 2478 欧拉函数打表的运用
http://poj.org/problem?id=2478 此题只是用简单的欧拉函数求每一个数的互质数的值会超时,因为要求很多数据的欧拉函数值,所以选用欧拉函数打表法. PS:因为最后得到的结果会很 ...
- [luoguP2184] 贪婪大陆(树状数组)
传送门 用两个树状数组,cr 维护 1....x 中 r 的数量 cl 维护 1....x 中 l 的数量 求答案的时候只需要求 y 前面 被作为左端点 的个数 - x 前面 被作为右端点的个数 —— ...
- 【dp】D. Caesar's Legions
https://www.bnuoj.com/v3/contest_show.php?cid=9146#problem/D [题意]给定n1个A,n2个B,排成一排,要求A最多能连续k1个紧挨着,B最多 ...
- jquery的ajax提交时“加载中”提示的处理方法
方法1:使用ajaxStart方法定义一个全局的“加载中...”提示 $(function(){ $("#loading").ajaxStart(function(){ ...
- 解决maven Generating project in Interactive mode
在idea建一个基于maven结构的web项目时,cmd输出卡死在Generating project in Interactive mode不动了 用命令mvn archetype:generate ...