HDU 2143 Can you find it?(基础二分)
Can you find it?
Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/10000 K (Java/Others)
Total Submission(s): 42520 Accepted Submission(s): 10315
#include <iostream>
#include <stack>
#include <string.h>
#include <stdio.h>
#include<queue>
#include<algorithm>
#define ll long long
using namespace std;
int a[];
int b[];
int c[];
int sum[];
int main()
{
int L,N,M;
int k=;
while(~scanf("%d %d %d",&L,&N,&M))
{
k++;
for(int i=;i<=L;i++)
{
scanf("%d",&a[i]);
}
for(int i=;i<=N;i++)
{
scanf("%d",&b[i]);
}
for(int i=;i<=M;i++)
{
scanf("%d",&c[i]);
}
int n,x;
printf("Case %d:\n",k);
scanf("%d",&n);
int p=; for(int i=;i<=L;i++)
{
for(int j=;j<=N;j++)
{
sum[p++]=a[i]+b[j];
}
}
sort(sum+,sum+p);
sort(c+,c++M);
while(n--)
{
scanf("%d",&x);
bool f=;
for(int i=;i<=M;i++)
{
if(sum[]>x-c[i])//不能写成sum[1]+c[1]>x,因为可能会爆int
break;
int le=;int ri=p-;
while(le<=ri)
{
int mid=(le+ri)/;
if(sum[mid]==x-c[i])
{
f=;
break;
}
else if(sum[mid]>x-c[i])
{
ri=mid-;
}
else if(sum[mid]<x-c[i])
le=mid+;
}
if(f)
break;
}
if(f)
printf("YES\n");
else
printf("NO\n");
}
}
return ;
}
HDU 2143 Can you find it?(基础二分)的更多相关文章
- HDU 2254 奥运(矩阵高速幂+二分等比序列求和)
HDU 2254 奥运(矩阵高速幂+二分等比序列求和) ACM 题目地址:HDU 2254 奥运 题意: 中问题不解释. 分析: 依据floyd的算法,矩阵的k次方表示这个矩阵走了k步. 所以k ...
- hdu 2143 数组合并 二分
Can you find it? Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/10000 K (Java/Others ...
- hdu.. 基础二分的精度问题
#include<stdio.h>#include<iostream>using namespace std;double f(double x){ return 8*x*x* ...
- HDU 2236:无题II(二分搜索+二分匹配)
http://acm.hdu.edu.cn/showproblem.php?pid=2236 题意:中文题意. 思路:先找出最大和最小值,然后二分差值,对于每一个差值从下界开始枚举判断能不能二分匹配. ...
- HDU 4282 A very hard mathematic problem 二分
A very hard mathematic problem Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/sh ...
- hdu 1839 Delay Constrained Maximum Capacity Path 二分/最短路
Delay Constrained Maximum Capacity Path Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu. ...
- HDU 5954 - Do not pour out - [积分+二分][2016ACM/ICPC亚洲区沈阳站 Problem G]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5954 Problem DescriptionYou have got a cylindrical cu ...
- HDU 2141 Can you find it? (二分)
题目链接: Can you find it? Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/10000 K (Java/ ...
- hdu 2141 Can you find it?(二分查找)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2141 题目大意:查找是否又满足条件的x值. 这里简单介绍一个小算法,二分查找. /* x^2+6*x- ...
随机推荐
- Hadoop平台的基本组成与生态系统
Hadoop系统运行于一个由普通商用服务器组成的计算集群上,该服务器集群在提供大规模分布式数据存储资源的同时,也提供大规模的并行化计算资源. 在大数据处理软件系统上,随着Apache Hadoop系统 ...
- js的数组与对象关系
有的时候总犯糊涂,不理解对象和数组的关系,转载一篇文章,深刻记忆一下 http://hi.baidu.com/samdan/item/05179313d1ee4b9e99ce3371 比如有一个数组a ...
- Html中的表格
表格由<table>标签来定义.每个表格均有若干行(由<tr> 标签定义),每行被分割为若干单元格(由<td>标签定义). 字母 td 指表格数据(table da ...
- 流量监控iftop安装-CentOS7
继之前撘的服务器后路由器一直崩溃,今天找到了原因.之前被下的木马并没有被删掉,而是一直在传输数据.占用了所有宽带. 官网(http://www.ex-parrot.com/pdw/iftop/down ...
- office-word
目录(大纲) word中大纲的视图(也就是目录)是根据1/2/3级大纲决定的 格式刷 可以刷成一样的格式,字体,编号以及大纲等等. 主要用于编号和目录,快捷键(ctrl+shift) 编号设置(不建议 ...
- 棋盘分割(二维区间DP)
题目大意:给一个棋盘,棋盘上每个格子中都有一个值,现在需要将棋盘切成n个矩形,总共切n-1刀,求最小的均方差.均方差定义为:,其中. 题目分析:将均方差化简得到:均方差2=(Σxi2)/n-平均值2. ...
- redis集群登陆
如何登陆redis集群 redis-cli -h 10.12.4.45 -p 7000 -c -a alkdsjf134rj01 ip:10.12.4.45 集群中的一个点 -c 以集群方式登陆.cl ...
- 前端常用框架和js插件 UI组件等
前言:写这个随笔,是记录一下工作以来用到的各种框架.以免日后忘记: JS库: 1. jquery.js 2. zepto.js ----jquery的精简版,专门用于手机上的,但是zepto主体默认是 ...
- asp.net中的时间日期选择控件
asp.net中的时间日期选择控件 Posted on 2008-07-17 17:37 飛雪飄寒 阅读(22922) 评论(6) 编辑 收藏 在系统中经常需要进行时间日期选择(比如查询时间范 ...
- 『转』Kaspersky Internet Security for Android &KMS – 免费6个月
卡巴越南的活动,需要注册账户,完成小调查,24小时内发送激活码,激活码3个月内有效.建议用谷歌翻译下网站.KIS for Android 的激活码也通用于 Kaspersky Mobile Secur ...