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 查找的更多相关文章

  1. zoj 1760 floyd构图+Dinic最大流

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1760 #include <cstdio> #includ ...

  2. zoj 1760 Doubles(set集合容器的应用)

    题目链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1760 题目描述: As part of an arithmet ...

  3. zoj 1760 Doubles

    Doubles Time Limit: 2 Seconds      Memory Limit: 65536 KB As part of an arithmetic competency progra ...

  4. ZOJ 3156 Taxi (二分匹配+二分查找)

    题目链接:Taxi Taxi Time Limit: 1 Second      Memory Limit: 32768 KB As we all know, it often rains sudde ...

  5. ZOJ 3492 模拟循环链表线性查找

    WA了好几次最后找到错因是因为数组开小了! = = string whose length never exceeds 20 所以至少要开到21 = = ,我却一直开20 ╮(╯▽╰)╭ AC代码: ...

  6. ZOJ 3203 Light Bulb (三分查找)

    Light Bulb Time Limit: 1 Second      Memory Limit: 32768 KB Compared to wildleopard's wealthiness, h ...

  7. ZOJ题目分类

    ZOJ题目分类初学者题: 1001 1037 1048 1049 1051 1067 1115 1151 1201 1205 1216 1240 1241 1242 1251 1292 1331 13 ...

  8. HDU 4430 &amp; ZOJ 3665 Yukari&#39;s Birthday(二分法+枚举)

    主题链接: HDU:pid=4430" target="_blank">http://acm.hdu.edu.cn/showproblem.php?pid=4430 ...

  9. ZOJ 3228 Searching the String(AC自动机)

    Searching the String Time Limit: 7 Seconds      Memory Limit: 129872 KB Little jay really hates to d ...

随机推荐

  1. Python面向对象(定义类和创建对象)

    day24 http://www.cnblogs.com/wupeiqi/p/4493506.html Python:函数式+面向对象,函数式编程可以做所有事,但是不一定合适. 小明,10岁,男,上山 ...

  2. mxonline实战14,全局搜索,修改个人中心页面个人资料信息

    对应github地址:第14天   一. 全局搜索   1. 使用关键词搜索 courses/views.py/CourseListView新增代码,不用把search_keywords传到前端

  3. 关于找不到stdafx.h头文件问题(pass)

    代码: #include "stdafx.h" #include "stdlib.h" char* getcharBuffer() { return " ...

  4. FPGA实战操作(2) -- PCIe总线(协议简述)

    目录 1. PCIe基础知识 2. 事务层协议 2.1 数据包结构 2.2 帧头含义详述 3. 报文举例 3.1 寄存器读报文 3.2 完成报文 4. 机制简述 4.1 Non-Posted和Post ...

  5. v-bind、v-on 的缩写

    Vue中的缩写:v-bind.v-on v-bind 缩写:: 预期:any (with argument) | Object (without argument) 参数:attrOrProp (op ...

  6. UNIX基础概念

    UNIX基本概念 进程 从用户观点来看:进程是程序的一个执行实例. 从UNIX系统内部来看,是为运行程序提供执行环境的实体,是系统进行资源分配和调度运行的一个单位. 进程有三个特点: 1)进程有一个控 ...

  7. Python PIL库学习笔记

    1.PIL简介 Python Imaging Library(缩写为PIL)(在新的版本中被称为Pillow)是Python编程语言的开源库,它增加了对打开,操作和保存许多不同图像文件格式的支持.它适 ...

  8. hadoop完全分布式手动安装(一主多从centos linux各版本均试验成功,文档完整无一遗漏)

    hadoop完全分布式手动安装(一主多从centos linux各版本均试验成功,文档完整无一遗漏) 网上的文章99%都是垃圾,我凭良心书写,确保幼儿园同学也能安装成功! 查看系统环境    1.查看 ...

  9. Java LinkedHashMap 逆序遍历

    利用 ListIterator<pre name="code" class="java">previous import java.util.Arr ...

  10. 多线程编程(三)-CountDownLatch的使用

    CountDownLatch的介绍 类CountDownLatch是同步功能得一个辅助类,使用效果就是给定一个计数,当使用CountDownLatch类的线程判断计数不为0时,则呈wait状态,如果是 ...