博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
杭电2141--Can you find it?
阅读量:7301 次
发布时间:2019-06-30

本文共 2100 字,大约阅读时间需要 7 分钟。

Can you find it?

Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/10000 K (Java/Others)

Total Submission(s): 17556    Accepted Submission(s): 4439

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
 

 

Author
wangye
 

 

Source
 

 

Recommend
威士忌   |   We have carefully selected several similar problems for you:          
//二分法, 查找的是有序数组的下标,  
1 #include 
2 #include
3 using namespace std; 4 int a[550], b[550], c[550]; __int64 d[250050]; 5 int main() 6 { 7 int l,m ,n, cas=1; 8 while(cin >> l >> m >> n) 9 {10 11 int i, j, k, t=0;12 for(i=0; i
> a[i];14 for(i=0; i
> b[i];16 for(i=0; i
> c[i];18 for(i=0; i
> sum;28 int ok = 0;29 for(i=0; i
=sum) //32 {33 int l=0, r=t-1, mid;34 while(r-l >= 0)35 {36 mid = (l+r)/2;37 if(c[i] + d[mid] > sum) r = mid -1;38 else if(d[mid] + c[i] < sum) l = mid + 1;39 else40 { ok = 1; break;} 41 }42 if(ok) break;43 }44 }45 if(ok)46 printf("YES\n");47 else48 printf("NO\n");49 }50 }51 return 0;52 }

//感觉二分法做的确实有点懵。

转载于:https://www.cnblogs.com/soTired/p/4691178.html

你可能感兴趣的文章
JAVA 多用户商城系统b2b2c---配置中心和消息总线
查看>>
使用Kubespray部署Kubernetes集群
查看>>
Intellij IDEA 部署应用到容器服务 Kubernetes
查看>>
Google希望从搜索结果展现中了解搜索结果的内容
查看>>
Udacity并行计算课程笔记-The GPU Programming Model
查看>>
【对讲机的那点事】就在身边却不露面的朋友--无线电波
查看>>
Java读取XML与xls文件
查看>>
如何通过一个SAPGUI屏幕反查这个屏幕对应的事务码
查看>>
生物数据库搭建教程①——在Ubuntu14.04上部署LAMP环境
查看>>
Android Keyboard(自定义输入法)
查看>>
Serverless架构的演进
查看>>
自定义 DependencyProperty 与 RoutedEvent
查看>>
[WPF疑难]ErrorTemplate显示与隐藏问题
查看>>
如何不用 transition 和 animation 也能做网页动画
查看>>
Spark架构原理
查看>>
【全面解禁!真正的Expression Blend实战开发技巧】第十章 FluidMoveBehavior完全解析之三飞出ListBox吧...
查看>>
checkstyle 使用
查看>>
第十五章:交互式界面(十)
查看>>
Android 隐藏显示键盘
查看>>
必应搜索昨晚开始恢复正常访问
查看>>