HDU 5522 Numbers 暴力
Numbers
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5522
Description
Input
There are multiple test cases, no more than 1000 cases.
First line of each case contains a single integer n.(3≤n≤100).
Next line contains n integers A1,A2....An.(0≤Ai≤1000)
Output
For each case output "YES" in a single line if you find such i, j, k, otherwise output "NO"
Sample Input
3 1 2
3
1 0 2
4
1 1 0 2
Sample Output
YES
NO
YES
HINT
题意
题解:
就n^2暴力,先排序然后从大到小枚举i,把右边的数用一个数组标记其出现过,再枚举左边的数判断其加上Ai是否出现过.
代码
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<map>
using namespace std; map<int,int> H;
int a[];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
H.clear();
for(int i=;i<=n;i++)
scanf("%d",&a[i]),H[a[i]]++;
sort(a+,a++n);
int flag = ;
for(int i=;i<=n;i++)
{
H[a[i]]--;
for(int j=;j<i;j++)
if(H[a[j]+a[i]])
flag = ;
if(flag)
break;
}
if(flag)
printf("YES\n");
else
printf("NO\n");
}
}
HDU 5522 Numbers 暴力的更多相关文章
- HDU 5522 Numbers
水题 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> us ...
- HDU 6168 - Numbers | 2017 ZJUT Multi-University Training 9
/* HDU 6168 - Numbers [ 思维 ] | 2017 ZJUT Multi-University Training 9 题意: .... 分析: 全放入multiset 从小到大,慢 ...
- Hdu oj 5522 Numbers 之解题报告
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABCwAAAL7CAIAAAC5m4NqAAAgAElEQVR4nOy9e7QdVZUvXH+RMcJVdJ
- hdoj 5522 Numbers
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5522 水题:暴力过 #include<stdio.h> #include<strin ...
- hdu 5726 GCD 暴力倍增rmq
GCD/center> 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5726 Description Give you a sequence ...
- HDU 5510 Bazinga 暴力匹配加剪枝
Bazinga Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5510 ...
- hdu 5077 NAND(暴力打表)
题目链接:hdu 5077 NAND 题目大意:Xiaoqiang要写一个编码程序,然后依据x1,x2,x3的值构造出8个字符.如今给定要求生成的8个字符.问 说Xiaoqiang最少要写多少行代码. ...
- Educational Codeforces Round 23 C. Really Big Numbers 暴力
C. Really Big Numbers time limit per test 1 second memory limit per test 256 megabytes input standar ...
- hdu 4291(矩阵+暴力求循环节)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4291 思路:首先保留求出循环节,然后就是矩阵求幂了. #include<iostream> ...
随机推荐
- db file scattered read 等待事件
db file scattered read 等待事件: 我们经常会见到db file scattered read 等待事件,在生产环境中,这个等待事件可能更为常见.这个事件表明用户进程正在读数据 ...
- Delphi打开窗体时报"Corrupt Portfolio Stream"
今天在打开一个Delphi窗体时报了这么一个错误: Corrupt Portfolio Stream 查了一下,主要是由于Delphi窗体的*.ddp文件损坏引起的. 解决方法: 删除.ddp 文 ...
- xml-xml试题
ylbtech-doc:xml-xml试题 xml试题 1.A,xml试题返回顶部 01.{XML题目}关于XML声明正确的是.(选择1项) A)<!xml version=”1.0”!> ...
- android模块化app开发-3远程动态更新插件
前两章用apkplug框架实现了两个基本的功能,但它们都是在本地安装测试的,在实际开发过程中我们肯定是需要与服务器联网将更新的插件远程推送给用户手机客户端.今天利用apkplug提供的插件托管服务轻松 ...
- 在Ubuntu下安装Apache
在Ubuntu下安装软件其实非常方便,Ubuntu提供了apt-get工具,可以使用该工具直接下载安装软件. 在Linux里,系统最高权限账户为root账户,而默认登录的账户并非root账户,例如不具 ...
- CABasicAnimation 使用
1. 基本使用 UIView * view = [[UIView alloc]initWithFrame:CGRectMake(50, 50, 50,50)]; view.backgroundColo ...
- IOS UIScrollView中 使用 touch 无法响应的问题
添加一个 Category 然后在使用到 UIScrollView 的文件里面 导入这个头文件 就可以 // // UIScrollView+UITouch.m // alarm // // ...
- Selenium2Library系列 keywords 之 _SelectElementKeywords 之 get_selected_list_label(self, locator)
def get_selected_list_label(self, locator): """Returns the visible label of the selec ...
- 【转】发布python的包至pypi服务器
[原文链接]http://yejinxin.github.io/distribute-python-packages-to-pypi-server/ 使用pip或easy_install可以管理和安装 ...
- leetcode—Plus one
1.题目描述 Given a number represented as an array of digits, plus one to the number. 2.解法分析 不要被常规思路限制住 ...