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. Delphi2007 在Win10 下运行报错 Assertion failure

    Delphi2007 原来安装在Win7 下 运行正常, 自从升级到Win10 ,新建工程运行然后关闭报错, 报错信息如下: ---------------------------bds.exe - ...

  2. python如何通过windows命令行运行一个python程序文件?

    python如何通过windows命令行运行一个python程序文件? cmd 进入到py文件对应目录下或者直接在上面的文件地址栏输入cmd,敲入回车 定位到对应的目录下 输入python xxx.p ...

  3. 第3篇-超市管理系统Scrum冲刺博客

    一.站立式会议: 1.会议照片 2.昨天完成的工作 ①数据库方面:根据需求关系为在数据库中建立相关表的基本模型供后续参考. ②前端方面:完成了登录界面的设计:各个界面的草图:为各个界面选取合适的图片如 ...

  4. 一不小心把windows资源管理器给结束任务了 电脑黑屏了 怎么处理

    按键盘上的三个键,Ctrl+Shift+Esc来启动任务管理器: 在任务管理器界面的左上角,有一个“文件”按钮,点击它会出现下拉的“新建任务(运行)...”按钮 鼠标点了“新建任务(运行)...”会弹 ...

  5. 004-OpenStack-计算服务

    OpenStack-计算服务 [基于此文章的环境]点我快速打开文章 1.控制节点(controller) 1.1 创库授权  nova_api, nova, 和 nova_cell0 mysql CR ...

  6. Pyqt5开发一款小工具(翻译小助手)

    翻译小助手 开发需求 首先五月份的时候,正在学习爬虫的中级阶段,这时候肯定要接触到js逆向工程,于是上网找了一个项目来练练手,这时碰巧有如何进行对百度翻译的API破解思路,仿造网上的思路,我摸索着完成 ...

  7. P5008 [yLOI2018] 锦鲤抄(Tarjan+贪心)

    洛谷 题意: 给出一个有向图,每次可以删除存在入度的点及其出边,每次删除一个点可以获得其权值. 问最终能够获得的最大权值为多少. 思路: 考虑DAG:我们直接倒着拓扑序来选,即可将所有入度不为\(0\ ...

  8. woocommerce如何隐藏/显示product meta

    前面我们说了woocommerce如何隐藏SKU,那如果不想显示产品分类category和标签tag呢?我们知道SKU, Category list 和 Tag list在woocommerce产品页 ...

  9. 【使用篇二】SpringBoot访问静态资源(4)

    默认的,SpringBoot会从两个地方查找静态资源: classpath/static 的目录下 ServletContext 根目录下 一.classpath/static 的目录 在类路径下常见 ...

  10. Python进阶-XII serialize(序列化)、序列化模块

    一.serialize 序列化 1.什么叫序列化——将原本的字典.列表等内容转换成一个字符串的过程就叫做序列化. 比如,我们在python代码中计算的一个数据需要给另外一段程序使用,那我们怎么给?现在 ...