直接用库函数二分即可。

  1. #include <iostream>
  2. #include <cstring>
  3. #include <cstdlib>
  4. #include <cstdio>
  5. #include <cmath>
  6. #include <cctype>
  7. #include <algorithm>
  8. #include <numeric>
  9.  
  10. #define eps 1e-8
  11. using namespace std;
  12.  
  13. double len[];
  14.  
  15. int main () {
  16. ios :: sync_with_stdio(false);
  17. len[] = ;
  18. for (int i = ; i < ; ++ i) {
  19. len[i] = len[i - ] + 1.0 / (double)(i + );
  20. }
  21.  
  22. //cout << len[273] << endl;
  23. double n;
  24. while (cin >> n) {
  25. if (n - < eps) {
  26. break;
  27. }
  28. //cout << lower_bound(len, len + 300, n) - &len[0] << endl;
  29. printf ("%d card(s)\n", lower_bound(len, len + , n) - &len[]);
  30. }
  31. return ;
  32. }

【POJ1003】Hangover(二分搜索)的更多相关文章

  1. [POJ1003]Hangover

    [POJ1003]Hangover 试题描述 How far can you make a stack of cards overhang a table? If you have one card, ...

  2. POJ1003 – Hangover (基础)

    Hangover   Description How far can you make a stack of cards overhang a table? If you have one card, ...

  3. POJ-1003&1004

    这两题比较简单,就不做分析了,描述下题目,就上代码吧. [题目描述] 1003,其实就是求这个方程的最小n:1/2 + 1/3 + 1/4 + ... + 1/(n + 1) >= c: 100 ...

  4. Hangover[POJ1003]

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 121079   Accepted: 59223 Descr ...

  5. [LeetCode] Largest BST Subtree 最大的二分搜索子树

    Given a binary tree, find the largest subtree which is a Binary Search Tree (BST), where largest mea ...

  6. poj 1003:Hangover(水题,数学模拟)

    Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 99450   Accepted: 48213 Descri ...

  7. hdu 2199 Can you solve this equation?(二分搜索)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  8. hdu 2199:Can you solve this equation?(二分搜索)

    Can you solve this equation? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ( ...

  9. 二分搜索 UVALive 6076 Yukari's Birthday (12长春K)

    题目传送门 题意:问使得sum (k^i) = n || n -1 (1 <= i <= r) 的min (r*k)组合的r和k  分析:r的最大不会超过40,枚举r,二分搜索k.注意会爆 ...

随机推荐

  1. [置顶] 【cocos2d-x入门实战】微信飞机大战之十三:游戏场景过渡

    原创作品,转载请标明:http://blog.csdn.net/jackystudio/article/details/12082043 游戏是实现了,但是如果有个欢迎界面和一个结束界面就更好了. 欢 ...

  2. jquery图片3D旋绕效果 rotate3Di的操作

    这是一个图片效果,很简单实用,只需要一个"rotate3Di.js"的插件就行, 关于rotate的用法有如下几种: $(选择器).rotate3Di(30); //把图片3D旋转 ...

  3. WPF - 为什么不能往Library的工程中添加WPF window

    项目中添加一个Library 工程,但是却无法加入WPF window, WPF customize control. 调查了一下,发现这一切都由于Library工程中没有:ProjectTypeGu ...

  4. 在Windows7上搭建Cocos2d-x win32开发环境

    很多其它相关内容请查看本人博客:http://www.bokeyi.com/ll/category/cocos2d-x/ 建议:为了避免安全相关的问题,请以管理员权限执行全部的操作,当执行命令的时候, ...

  5. .NET--接口设计

    我们学习.net视频的时候,老师讲的是"介面设计",有意思的是,这里的介面不是我们想象中的界面的意思,而是接口的意思. 由于视频是Micorsoft公司做的,所以整个视频看下来.仅 ...

  6. 如何给你的Android 安装文件(APK)瘦身

    如何给你的Android 安装文件(APK)瘦身 本文翻译自:Putting Your APKs on Diet           原作者:Cyril Mottier Android的apk文件越来 ...

  7. Ubuntu中设置静态IP和DNS(转载)

    原文地址:http://blog.sina.com.cn/s/blog_669421480102v3bb.html VMware 中使用网络,对虚拟机设置静态IP:在Ubuntu中设置静态IP共两步: ...

  8. .net 调用Oracle.Data.Access 组件提供的用于批量操作的方法—获取数据库表结构方法和跟参数赋值方法

    1./// <summary> /// 获取当前目标表结构 /// </summary> /// <param name="tableName"> ...

  9. 控制反转IOC与依赖注入DI【转】

    转自:http://my.oschina.net/1pei/blog/492601 一直对控制反转.依赖注入不太明白,看到这篇文章感觉有点懂了,介绍的很详细. 1. IoC理论的背景我们都知道,在采用 ...

  10. js实现楼层效果

    今天自己写个楼层效果,有一点烦躁,小地方犯错误.各位大神来修改不足啊!!! <!DOCTYPE html><html lang="en"><head& ...