Can you find it?(hdu 2141 二分查找)
Can you find it?
Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/10000 K (Java/Others)
Total Submission(s): 19416 Accepted Submission(s): 4891
1 2 3
1 2 3
1 2 3
3
1
4
10
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
int a[],b[],c[],x;
__int64 su[*];
int l,n,m,s,u;
int d=,sum;
bool solve(int x)
{
int i,k;
int ans;
for(i=;i<m;i++)
{
ans=x-c[i];
int l=,r=u-,mid,e;
while(l<=r)
{
mid=(l+r)/;
if(su[mid]==ans) return ;
else if(su[mid]>ans) r=mid-;
else l=mid+;
}
}
return ;
}
int main()
{
int i,j;
freopen("in.txt","r",stdin);
while(scanf("%d%d%d",&l,&n,&m)!=EOF)
{
for(i=;i<l;i++) scanf("%d",&a[i]);
for(i=;i<n;i++) scanf("%d",&b[i]);
for(i=;i<m;i++) scanf("%d",&c[i]);
scanf("%d",&s);
u=;
for(i=;i<l;i++)
for(j=;j<n;j++)
su[u++]=a[i]+b[j];
sort(su,su+u);
printf("Case %d:\n",d++);
for(i=;i<s;i++)
{
scanf("%d",&x);
if(solve(x)) printf("YES\n");
else printf("NO\n");
}
}
}
Can you find it?(hdu 2141 二分查找)的更多相关文章
- Equations(hdu 1496 二分查找+各种剪枝)
Equations Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- Pie(hdu 1969 二分查找)
Pie Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- hdu 2141 Can you find it?(二分查找)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2141 题目大意:查找是否又满足条件的x值. 这里简单介绍一个小算法,二分查找. /* x^2+6*x- ...
- hdu 2141:Can you find it?(数据结构,二分查找)
Can you find it? Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/10000 K (Java/Others ...
- hdu 2141 Can you find it?(二分查找变例)
Problem Description Give you three sequences of numbers A, B, C, then we give you a number X. Now yo ...
- Can you find it? HDU - 2141 (二分查找)
Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate ...
- HDU 2141 Can you find it?【二分查找是否存在ai+bj+ck=x】
Give you three sequences of numbers A, B, C, then we give you a number X. Now you need to calculate ...
- HDU 2141 Can you find it? (二分)
题目链接: Can you find it? Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/10000 K (Java/ ...
- 二分查找 HDOJ 2141 Can you find it?
题目传送门 /* 题意:给出一个数,问是否有ai + bj + ck == x 二分查找:首先计算sum[l] = a[i] + b[j],对于q,枚举ck,查找是否有sum + ck == x */ ...
随机推荐
- TypeError: not enough arguments for format string
到一个问题,表示100% 的时候,出现这个问题. 因为python语法会认为是你需要转移符,这个时候你可以选择100%% 来表示
- filter 以及 orderBy的使用
filter用于关键字过滤操作,orderBy用于排序操作,运行界面如下: 点击标题Name与Email实现排序功能,输入框中输入关键字进行过滤,同时实现根据关键字进行过滤后进行排序操作: ng-re ...
- java.lang.OutOfMemoryError: unable to create new native thread(转)
解决 - java.lang.OutOfMemoryError: unable to create new native thread 工作中碰到过这个问题好几次了,觉得有必要总结一下,所以有了这篇文 ...
- 【转】CTS tests 4.2_r4
原文网址:http://www.xuebuyuan.com/1722006.html Precondition: 1.Get android sdk 2.Set adb to environment ...
- mysqli connect database and print
<?php $connect = mysqli_connect('localhost','root','','intertrading') or die('Unale to connect'); ...
- 独立写作(A or B)
开头:On contemporary society(一般的背景)/ With the advent of the technologically advanced society (the info ...
- OpenStackCLI调试及术语识记
1,Project are organizational units in the cloud,and are also known as tenants or accounts.Each user ...
- setOpaque(true);设置控件不透明
setOpaque(true);设置控件不透明setOpaque(false);设置控件透明
- 04747_Java语言程序设计(一)_第6章_图形界面设计(二)
例6.1声明一个面板子类,面板子类对象有3个选择框. class Panel1 extends JPanel { JCheckBox box1, box2, box3; Panel1() { box1 ...
- goahead webserver源码分析
1.一个txt文本架构图 main() | |--websOpenServer() | |-- websOpenListen() | ...