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 ...
随机推荐
- Linux Bash对拍
代码: #!/bin/bash while true; do ./rand > input //数据生成器 ./test < input > output //测试程序 ./std ...
- BestCoder Round #47 1003
solution : 就按题解敲了一遍,好久没写这种dp ; ; LL f[MAX][MAX]; ]; scanf( scanf(,b+); ...
- 【计算几何】FZU Problem 2270 Two Triangles
http://acm.fzu.edu.cn/problem.php?pid=2270 [题意] 给定6到10个点,从中选出6个不同的点组成两个三角形,使其中一个三角形可以通过另一个三角形平移和旋转得到 ...
- hdu 1421经典dp
#include<stdio.h> #include<stdlib.h> #define N 2001 #define inf 0x3fffffff int a[N],dp[N ...
- Codeforces936D. World of Tank
$n \leq 1e9$,$n*2$的网格里有$m_1+m_2 \leq 1e6$个障碍物,现有一坦克从$(0,1)$出发要到$(n+1,1/2)$,他每秒可以换行(纵坐标1变2或2变1)也可以发炮弹 ...
- resin web项目的 编码问题
问题描述: 服务器迁移,迁移以后Linux系统编码由 UTF-8 变成了GBK !!! 导致在resin 中运行java web项目,调用 http 接口,解析http 接口的返回内容 如:xml 时 ...
- make only output error/warning message( 编译时,只输出错误信息和警告信息)
make > /dev/null 这样,正常的信息被重定向输出到/dev/null,错误和警告信息会输出到标准错误设备(standard error,相对于标准输入/输出设备来说).
- 【electron系列之二】复制图片
// 复制图片 ipcMain.on("copy",(event, arg) =>{ const imagePath = path.join(appPath, `page/i ...
- loj6172 Samjia和大树(树形DP+找规律)
题目: https://loj.ac/problem/6172 分析: 首先容易得出这样的dp式子 然后发现后面那个Σ其实是两段区间,可以用总和减去中间一段区间表示,所以只要维护个前缀和就ok了 这样 ...
- Mysql数据库的事物
一 .事物的特性:ACID 数据库的事务必须具备ACID特性,ACID是指 Atomicity(原子性).Consistensy(一致性).Isolation(隔离型)和Durability(持久性) ...