poj 1003 [离线预处理 + 二分]
来源:互联网 发布:java编写计算器教程 编辑:程序博客网 时间:2024/06/16 18:36
#include <iostream>#include <string>#include <cstring>#include <cstdlib>#include <cstdio>#include <cmath>#include <vector>#include <stack>#include <queue>#include <map>#include <set>#include <iterator>#include <algorithm>#define MID(x,y) ( ( x + y ) >> 1 )#define L(x) ( x << 1 )#define R(x) ( x << 1 | 1 )#define BUG puts("here!!!");#define STOP system("pause");using namespace std;const int N = 300;const double norm = 0.00000001;int zero(double x) {if(x < -norm) return -1;return x > norm;}int main() {double len[N];int total;len[0] = 0.0;for(total = 1; zero(len[total-1] - 5.20) <= 0; total++) { len[total] = len[total - 1] + 1.0 / double(total + 1);}double x;while(cin >> x, zero(x)) {int l, r;l = 0, r = total;while(l <= r) {int mid = MID(l, r);if(zero(len[mid] - x) <= 0) {l = mid + 1;}else r = mid - 1;}cout << r + 1 << " card(s)" << endl;}return 0;}
- poj 1003 [离线预处理 + 二分]
- poj 2739 [离线预处理 + 枚举]
- POJ 2761 树状数组+二分+离线
- POJ 3601 Escape from Enemy Territory (二分+BFS+预处理)
- poj 3501 Escape from Enemy Territory(预处理&二分&bfs)
- bzoj2743 HEOI2012采花 离线预处理
- HRBUST 1365 预处理+二分+?
- SPOJ - PHT【二分+预处理】
- poj 2112 Optimal Milking 【最大流 简单题】 【floyd预处理最短路 + 二分 + 最大流】
- POJ 3110 Jenny's First Exam (二分 + 树状数组 + 贪心 + 预处理年份)
- Poj 1358 Housing Complexes【二分匹配+二维前缀和预处理建图】
- 每日三题-Day1-A(POJ 1358 Housing Complexes 预处理+二分匹配)
- poj 3419 Difference Is Beautiful (dp+二分+RMQ或者dp+离线线段树)
- 从零开始天池新人离线赛-数据预处理
- UVa10856 - Recover Factorial(预处理+二分)
- hdu 4791 dp预处理+二分
- POJ 2661 预处理
- POJ 2029 预处理
- Keytool使用总结
- VC获取MAC地址
- windows下运行PYTHON程序准备
- linux的基础入门知识 (想要学好必须的看看)
- 实现验证码的代码(有注释)教会你怎样实现验证码!
- poj 1003 [离线预处理 + 二分]
- Oracle回收站使用详解
- Ubuntu11.10 kvm Fix: failed to find romfile "pxe-rtl8139.bin"
- Android 开机自启动应用
- 设计模式学习-----观察者模式
- Android Intent Action 大全
- android4.0 MediaPlayer的notify监听机制的全面剖析
- 总帐凭证导入EXCEL,并且批量输入(FB50)的BDC
- java setBinaryStream error for mysql