zoj 1760 查找
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=760
撸了个二分查找
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
using namespace std; int bs(int a[],int n,int len)
{
int lo = ,hi = len-,mid = (lo+hi)/;
while(lo<=hi)
{
if(n<a[mid])
{
hi = mid -;
mid = (lo+hi)/;
}
else if(n>a[mid])
{
lo = mid +;
mid = (lo+hi)/;
}
else
return mid;
}
if(lo>hi)
return -;
} int main()
{
int a[];
int x;
while(cin>>x && x!=-)
{
int i = ;
a[] = x;
while(cin>>a[i])
{
if(a[i]==)
break;
i++;
}
sort(a,a+i);
int count = ;
for(int j = i-;j>=;j--)
{
if(bs(a,a[j]*,i)!=-)
{
count++;
}
}
cout<<count<<endl; }
}
zoj 1760 查找的更多相关文章
- zoj 1760 floyd构图+Dinic最大流
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1760 #include <cstdio> #includ ...
- zoj 1760 Doubles(set集合容器的应用)
题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1760 题目描述: As part of an arithmet ...
- zoj 1760 Doubles
Doubles Time Limit: 2 Seconds Memory Limit: 65536 KB As part of an arithmetic competency progra ...
- ZOJ 3156 Taxi (二分匹配+二分查找)
题目链接:Taxi Taxi Time Limit: 1 Second Memory Limit: 32768 KB As we all know, it often rains sudde ...
- ZOJ 3492 模拟循环链表线性查找
WA了好几次最后找到错因是因为数组开小了! = = string whose length never exceeds 20 所以至少要开到21 = = ,我却一直开20 ╮(╯▽╰)╭ AC代码: ...
- ZOJ 3203 Light Bulb (三分查找)
Light Bulb Time Limit: 1 Second Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...
- ZOJ题目分类
ZOJ题目分类初学者题: 1001 1037 1048 1049 1051 1067 1115 1151 1201 1205 1216 1240 1241 1242 1251 1292 1331 13 ...
- HDU 4430 & ZOJ 3665 Yukari's Birthday(二分法+枚举)
主题链接: HDU:pid=4430" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=4430 ...
- ZOJ 3228 Searching the String(AC自动机)
Searching the String Time Limit: 7 Seconds Memory Limit: 129872 KB Little jay really hates to d ...
随机推荐
- powerdesign设计、实现简单的数据库模型
1,新建CDM,打开powerdesign,选择Categories----Infoomation------Conceptual Data.开始画图,如果此时如表示关系的图标是灰色的.Tools-- ...
- SQL面试题(网络收集)
1. 用一条SQL 语句 查询出每门课都大于80 分的学生姓名 name kecheng fenshu 张三 语文 81 张三 数学 75 李四 ...
- 【性能测试】jmeter的坑(1)——如何在多网卡情况下正确连接
问题现象: 性能测试时,使用的服务器配置了双网卡,windows客户机配置了四网卡,坑爹的配置,内外网的隔离,导致在使用jmeter进行分布式测试的时候总是连接失败. 原因分析: Jmeter采用了r ...
- Java_多线程2_线程池
线程池(pool): 线程池的作用: 1.节省资源,减少线程的数量和创建销毁线程的开销2.合理的管理线程的分配 线程池的创建: 1.newCachedThreadPool //优点:很灵活,弹性的线程 ...
- CentOS下安装Docker
简介:本篇文章介绍如何在CentOS系统下面安装docker系统. 官方文档:https://docs.docker.com/install/linux/docker-ce/centos/ Docke ...
- Spring由于web配置导致的spring配置文件找不到的问题的解决方案
在把某项技术整合到Spring中的时候,我们时常会发现报如下错误: org.springframework.beans.factory.BeanCreationException: Error cre ...
- HUE配置文件hue.ini 的sqoop模块详解(图文详解)(分HA集群和非HA集群)
不多说,直接上干货! 我的集群机器情况是 bigdatamaster(192.168.80.10).bigdataslave1(192.168.80.11)和bigdataslave2(192.168 ...
- javac的Resolve类解读
方法1:isInitializer() /** An environment is an "initializer" if it is a constructor or * an ...
- JavaScript数据结构-12.散列碰撞(线性探测法)
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- seajs模块路径解析 简单总结
最近在试着用 seajs + grunt 搭建项目雏形, 遇到的最大的问题就是 seajs 命名与调用, 简单总结一下. 模块调用 seajs中调用模块有两种方式,seajs.use(ID) . re ...