HDU 2578 Dating with girls(1) [补7-26]
Dating with girls(1)
Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3869 Accepted Submission(s): 1196
in the HDU knows that the number of boys is larger than the number of
girls. But now, every boy wants to date with pretty girls. The girls
like to date with the boys with higher IQ. In order to test the boys '
IQ, The girls make a problem, and the boys who can solve the problem
correctly and cost less time can date with them.
The
problem is that : give you n positive integers and an integer k. You
need to calculate how many different solutions the equation x + y = k
has . x and y must be among the given n integers. Two solutions are
different if x0 != x1 or y0 != y1.
Now smart Acmers, solving the problem as soon as possible. So you can dating with pretty girls. How wonderful!

first line contain an integer T. Then T cases followed. Each case
begins with two integers n(2 <= n <= 100000) , k(0 <= k <
2^31). And then the next line contain n integers.
5 4
1 2 3 4 5
8 8
1 4 5 7 8 9 2 6
5
#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 123456
#define M 1234 int n,k;
int a[N];
int main()
{
int t;cin>>t;
while(t--)
{
scanf("%d%d",&n,&k);
int ha[N]={};
int j=,c;
for(int i=;i<n;i++)
{
scanf("%d",&c);
if(c>k || ha[c])continue;
a[j++]=c;
ha[c]=;
}
int cnt=;
for(int i=;i<j;i++)
if(ha[ k-a[i] ])
cnt++; cout<<cnt<<endl;
}
return ;
}
HDU 2578 Dating with girls(1) [补7-26]的更多相关文章
- HDU 3784 继续xxx定律 & HDU 2578 Dating with girls(1)
HDU 3784 继续xxx定律 HDU 2578 Dating with girls(1) 做3748之前要先做xxx定律 对于一个数n,如果是偶数,就把n砍掉一半:如果是奇数,把n变成 3*n+ ...
- hdu 2578 Dating with girls(1)
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2578 Dating with girls(1) Description Everyone in the ...
- hdu 2578 Dating with girls(1) (hash)
Dating with girls(1) Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- hdu 2578 Dating with girls(1) 满足条件x+y=k的x,y有几组
Dating with girls(1) Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- hdu 2579 Dating with girls(2)
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=2579 Dating with girls(2) Description If you have sol ...
- hdu 2579 Dating with girls(2) (bfs)
Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- Dating with girls(1)(二分+map+set)
Dating with girls(1) Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- 二分-B - Dating with girls(1)
B - Dating with girls(1) Everyone in the HDU knows that the number of boys is larger than the number ...
- hdoj 2579 Dating with girls(2)【三重数组标记去重】
Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
随机推荐
- mysql常见监控项
1.MySQL服务运行状态 约定所有MySQL服务都必须以ip1(内网ip)来绑定,每个机器只有一个ip1,可以有多个端口,即多个MySQL Server.采集程序读取ip端口信息文件来判断serve ...
- 推荐SQL Server Management Studio以及Visual Studio下的免费的插件 ApexSQL Complete
SQL Server 并没有代码格式化的工具,对于处理他人编写的长SQL需要手工的格式化是一件麻烦的事情. 推荐SQL Server Management Studio以及Visual Studio下 ...
- Thymeleaf模板引擎+Spring整合使用方式的介绍
尊重原创,原文地址为:https://www.cnblogs.com/jiangchao226/p/5937458.html 前言 这个教程介绍了Thymeleaf与Spring框架的集成,特别是Sp ...
- Java总结输入流输出流
学习Java的同学注意了!!! 学习过程中遇到什么问题或者想获取学习资源的话,欢迎加入Java学习交流群:618528494 我们一起学Java! 1.什么是IO Java中I/O操作主要是指使用 ...
- log4net.dll配置以及在项目中应用
1,首先在项目中引用log4net.dll,然后项目中添加一个配置文件log4net.config <?xml version="1.0" encoding="ut ...
- Windows 安装 composer
在 composer.phar 同级目录下新建文件 composer.bat : C:\bin>echo @php "%~dp0composer.phar" %*>co ...
- Virtual Box 安装过程(卸载Vmware后)
VirtualBox安装前的操作:(或许某些操作不一定有用,但是我是这么做下来的,最后也安装成功了) 步骤一:停止之前安装的vmware的所有服务(如果之前没有安装过虚拟机软件,无需做此操作)VMwa ...
- JQuery Mobile 的引用代码,以及在手机浏览器上字体太小的解决办法
JQuery Mobile 的引用代码: <link rel="stylesheet" href="http://code.jquery.com/mobile/1. ...
- 把项目变成intellij idea和eclipse项目
就通过maven把它build成一个IDE项目,执行以下命令,打开CMD: $ cd 项目名 $ mvn eclipse:eclipse or mvn idea:idea
- sqlserver通过设计器修改表结构保存时提示:保存到文本问题
在sqlserver通过设计器修改表结构后保存时提示:保存到文本问题,这个问题可能通过修改设置项解决 工具>选项>设计器> 在弹出的窗口是把“阻止保存要求重新创建表的更改”选项的 ...