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> ...
随机推荐
- 【转】 CATransform3D 矩阵变换之立方体旋转实现细节
原文网址:http://blog.csdn.net/ch_soft/article/details/7351896 第一部分.前几天做动画,使用到了CATransform3D ,由于没有学过计算机图形 ...
- 安装oracle XML Database 组件
近期部署项目数据库,编译包时遇到错误: PACKAGE CTG.CTG_CSB_COMMON 编译错误 错误:PLS-00201: identifier 'XMLDOM' must be dec ...
- validate.plugin.js 验证插件
/*编写时间:2015-6-4*/ (function ($) { $.fn.isValidate = function (obj) { if ($(this).val()!="" ...
- js把div固定在页面的右下角
在公司做材料系统中,需要做一个总是居于右下角的div,但是因为右边这部分本就是用iframe做的,所以是不好弄的. 一开始,以为用position:fixed,一句css就可以完成,结果在iframe ...
- android模块化app开发笔记-2插件间布局文件共享
android编程时布局文件,图片资源等都是放在同一个文件夹下,这样照成一个问题就是我们想重用UI布局文件和图片时就还需要其分离这些资料,相信大部分android程序员都遇到过这样的问题,其痛苦程度不 ...
- 联通光纤上网配置+华为HG8240光猫+TL-WR842N
最近搬家改用北京联通宽带,光纤入户的那种.联通送的光猫是华为HG8240,没看到天线,应该是不带无线路由.然后自己再买了个TP-Link的TL-WR842N,用来组局域网,也供ipad.kindle. ...
- codedorces 260 div2 A题
水题,扫描一遍看是否出现价格低质量高的情况. #include<cstdio> #include<string> #include<vector> #include ...
- U盘安装Centos5.3
一.制作 U 盘启动引导盘 1. 插上 U 盘,打开 UltraISO 软件,打开CentOS-5.3-i386-bin-DVD.iso 文件: 2.点启动--写入硬盘镜像,在硬盘驱动器里面选择你的 ...
- IOS-day01_OC中类的创建以及使用
OC中定义类 // 设计一个车类 @implementation Car : NSObject // 这个大括号里面写所有的属性 { @public int wheels ;//轮子个数 double ...
- Hadoop学习之--Capaycity Scheduler配置参数说明
以下列举出来的是capacity关于queue和user资源使用量相关的参数说明: mapred.capacity-scheduler.queue.xxx.capacity: 队列的资源容量百分比,所 ...