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. Kali无法使用Chrome原因及解决方法

      Kali安装好后,默认的浏览器是Firefox-ESR(Extended Support Release 长期支持)版本.   作为Chrome的死忠粉,当然是要下Chrome用用的.   直到我 ...

  2. Java11新特性解读

    在去年的9月26日,Oracle官方宣布Java11正式发布,这是Java大版本周期变化后的第一个长期支持版本,非常值得关注.Java9和Java10都在很短的时间内就过渡了,所以,Java11将是一 ...

  3. [PHP] 广度优先搜索匹配网站所有链接

    <?php define('PRE_DOMAIN','www'); define('DOMAIN','sina.com.cn'); define('PROTOCOL','https'); def ...

  4. 在Ubuntu下使用nginx-rtmp-module搭建直播系统

    直播系统最简单地包括推流和拉流,在这里先使用nginx-rtmp-module作为流媒体服务器. 流媒体服务器搭建 1. nginx-rtmp-module下载和安装 源码地址:https://git ...

  5. DRL强化学习:

    IT博客网 热点推荐 推荐博客 编程语言 数据库 前端 IT博客网 > 域名隐私保护 免费 DRL前沿之:Hierarchical Deep Reinforcement Learning 来源: ...

  6. USACO Making the Grade

    洛谷 P2893 [USACO08FEB]修路Making the Grade https://www.luogu.org/problemnew/show/P2893 JDOJ 2566: USACO ...

  7. 论文阅读笔记六十四: Architectures for deep neural network based acoustic models defined over windowed speech waveforms(INTERSPEECH 2015)

    论文原址:https://pdfs.semanticscholar.org/eeb7/c037e6685923c76cafc0a14c5e4b00bcf475.pdf 摘要 本文研究了利用深度神经网络 ...

  8. mpich安装

    1.简介与下载 MPICH是一种高性能的.可广泛移植的实现来自阿尔贡国家实验室的MPI-3.1标准. https://www.mpich.org/downloads/ 2.解压安装 tar xzvf ...

  9. 11/5 <backtracking> 伪BFS+回溯

    78. Subsets While iterating through all numbers, for each new number, we can either pick it or not p ...

  10. bootstrap-table 列拖动

    1.页面js/css <!-- bootstrap 插件样式 --> <link th:href="@{/common/bootstrap-3.3.6/css/bootst ...