Can you find it?

Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/10000 K (Java/Others)
Total Submission(s): 37762    Accepted Submission(s): 9221

Problem Description
Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate if you can find the three numbers Ai, Bj, Ck, which satisfy the formula Ai+Bj+Ck = X.
 
Input
There are many cases. Every data case is described as followed: In the first line there are three integers L, N, M, in the second line there are L integers represent the sequence A, in the third line there are N integers represent the sequences B, in the forth line there are M integers represent the sequence C. In the fifth line there is an integer S represents there are S integers X to be calculated. 1<=L, N, M<=500, 1<=S<=1000. all the integers are 32-integers.
 
Output
For each case, firstly you have to print the case number as the form "Case d:", then for the S queries, you calculate if the formula can be satisfied or not. If satisfied, you print "YES", otherwise print "NO".
 
Sample Input
3 3 3
1 2 3
1 2 3
1 2 3
3
1
4
10
 
Sample Output
Case 1:
NO
YES
NO
 
思路:  首先将任意两个数组两两相加,保存到一个数组中,这个数组一定要开大一写,最好是500*500,排序,然后加这个新的数组和第三个数组相加,利用二分的思想进行查找。
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int al[],an[],am[],d[];
int main()
{
int l,n,m,s,flag=,s1;
while(~scanf("%d%d%d",&l,&n,&m))
{
for(int i=;i<=l;i++) scanf("%d",&al[i]);
for(int i=;i<=n;i++) scanf("%d",&an[i]);
for(int i=;i<=m;i++) scanf("%d",&am[i]);
int k=;
for(int i=;i<=l;i++){
for(int j=;j<=n;j++)
d[k++]=al[i]+an[j];
}
sort(d+,d+k);
scanf("%d",&s);
printf("Case %d:\n",flag++);
while(s--)
{
bool sign = false;
scanf("%d",&s1);
for(int i=;i<=m;i++)
{
int left=,right=k;
while(left<=right)
{
int middle = (left+right)/;
if(d[middle]+am[i]==s1) {sign = true; break;}
if(d[middle]+am[i]<s1) left = middle+;
else right= middle -;
}
}
if(sign) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
return ;
}

HDU 2007-11 Programming Contest的更多相关文章

  1. 2019-2020 ACM-ICPC Brazil Subregional Programming Contest (11/13)

    \(2019-2020\ ACM-ICPC\ Brazil\ Subregional\ Programming\ Contest\) \(A.Artwork\) 并查集,把检测区域能在一起的检测器放在 ...

  2. 2017-2018 ACM-ICPC Latin American Regional Programming Contest PART (11/13)

    $$2017-2018\ ACM-ICPC\ Latin\ American\ Regional\ Programming\ Contest$$ \(A.Arranging\ tiles\) \(B. ...

  3. 2017-2018 ACM-ICPC German Collegiate Programming Contest (GCPC 2017)(9/11)

    $$2017-2018\ ACM-ICPC\ German\ Collegiate\ Programming\ Contest (GCPC 2017)$$ \(A.Drawing\ Borders\) ...

  4. The 10th Shandong Provincial Collegiate Programming Contest(11/13)

    $$The\ 10th\ Shandong\ Provincial\ Collegiate\ Programming\ Contest$$ \(A.Calandar\) 签到 //#pragma co ...

  5. The Ninth Hunan Collegiate Programming Contest (2013) Problem L

    Problem L Last Blood In many programming contests, special prizes are given to teams who solved a pa ...

  6. Gym 100952E&&2015 HIAST Collegiate Programming Contest E. Arrange Teams【DFS+剪枝】

    E. Arrange Teams time limit per test:2 seconds memory limit per test:64 megabytes input:standard inp ...

  7. 2018 ACM-ICPC, Syrian Collegiate Programming Contest

    2018 ACM-ICPC, Syrian Collegiate Programming Contest A Hello SCPC 2018! 水题 B Binary Hamming 水题 C Por ...

  8. 2018 German Collegiate Programming Contest (GCPC 18)

    2018 German Collegiate Programming Contest (GCPC 18) Attack on Alpha-Zet 建树,求lca 代码: #include <al ...

  9. The 15th UESTC Programming Contest Preliminary B - B0n0 Path cdoj1559

    地址:http://acm.uestc.edu.cn/#/problem/show/1559 题目: B0n0 Path Time Limit: 1500/500MS (Java/Others)    ...

  10. 2016 China Collegiate Programming Contest Final

    2016 China Collegiate Programming Contest Final Table of Contents 2016 China Collegiate Programming ...

随机推荐

  1. 关于Qt 静态成员函数调用信号

    class globalCalcThread; extern globalCalcThread *g_calcThread; class globalCalcThread : public QThre ...

  2. Mybatis插入实体类字段为关键字解决方案

    1. Mybatis插入实体类字段为关键字解决方案 1.1. 前言 可能你插入字段为关键字时报如下错误,且字段名不适合改变 You have an error in your SQL syntax; ...

  3. 新手入门必看:VectorDraw 常见问题整理大全(一)

    VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库.有了VDF提供的功能,您可以轻松地创建.编辑.管理.输出.输入和打印2D和3D图形文件.该库 ...

  4. maven 学习---定制库到Maven本地资源库

    这里有2个案例,需要手动发出Maven命令包括一个 jar 到 Maven 的本地资源库. 要使用的 jar 不存在于 Maven 的中心储存库中. 您创建了一个自定义的 jar ,而另一个 Mave ...

  5. Python3——根据m3u8下载视频(下)之requests

    下半场ING,好吧,本来准备明天写的(拖延真快乐.gif),请然而,,,早上八点多跑公司加班(看书+学习)去,发现大门上挂着一把大锁,我只想说门禁是拿来看的嘛,加啥破锁o(╥﹏╥)o,严重打击了好员工 ...

  6. chm帮助文档显示字体过小

    问题描述: 在查看chm帮助文档时,发现默认显示字体过小,阅读吃力 解决方案: 1. 点击选项按钮->Internet 选项 2. 点击辅助功能 3. 选中 忽略网页上指定的字号,点击确定 最后 ...

  7. 错误: 找不到或无法加载主类 com.leyou.LeyouItemApplication Process finished with exit code 1

    在IDEA的使用过程中,经常断掉服务或者重启服务,最近断掉服务重启时突然遇到了一个启动报错: 错误:找不到或无法加载主类 猜测:1,未能成功编译: 尝试:菜单--->Build--->Re ...

  8. 2019.6.11_MySQL进阶三:临时表

    临时表 临时表主要应用于保存一些临时数据.临时表只在当前连接可见.当关闭连接时,MySQL会自动删除表并且释放空间.临时表在MySQL 3.23版本中添加,低于 3.23版本就无法使用MySQL的临时 ...

  9. Linux进程和计划任务管理

    1.笔记: 去掉头部:ps -aux - - no -heade 默认信号:15 强制:9 在命令前些一个nohup不再占用终端 date -s:修改时间 ntpdate pool.ntp.org:同 ...

  10. vue-loader和单页组件介绍

    一.Vue Loader介绍 Vue Loader 是一个 webpack 的loader,它允许你以一种名为 单文件组件(SFCs)的格式撰写 Vue 组件.官方文档地址如下所示: Vue Load ...