POJ 1003 Hangover
来源:互联网 发布:php就业形势 编辑:程序博客网 时间:2024/06/08 05:54
【题意】求1/2+1/3+1/4+...+1/n数列的s的前驱
【分析】还用说什么呢......
【代码】
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
double f[300],s;
int cmp(double i,double j)
{
if (fabs(i-j)<1e-6) return 0;
return i<j?-1:1;
}
int main(void)
{
for (int i=2;i<300;i++) f[i]=1.0/i;
for (int i=2;i<300;i++) f[i]+=f[i-1];
for (;;)
{
scanf("%lf",&s);
if (!cmp(s,0)) break;
for (int i=1;;i++) if (cmp(f[i],s)>=0) {printf("%d card(s)\n",i-1);break;}
}
return 0;
}
0 0
- POJ 1003--Hangover
- (POJ 1003)Hangover
- poj 1003Hangover
- POJ 1003 Hangover
- poj 1003 Hangover
- poj 1003(Hangover)
- 【POJ】1003 Hangover
- POJ-1003:Hangover
- [POJ]1003 Hangover
- POJ 1003 Hangover
- poj 1003 Hangover
- POJ 1003 Hangover
- 【POJ-1003】Hangover
- POJ-1003-Hangover
- poj 1003 Hangover
- POJ 1003 Hangover
- [POJ][1003]Hangover
- poj 1003 Hangover
- 杭电-2099 整除的尾数
- NOIP 2014 提高组 Day2 T1 无线网路发射器选址
- POJ 1001 Exponentiation
- POJ 1002 487-3279
- C#设计模式(十三)迭代器模式
- POJ 1003 Hangover
- 用 Tomcat 和 Eclipse 开发 Web 应用程序
- POJ 1004 Financial Management
- POJ 1005 I Think I Need a Houseboat
- Tomcat全攻略
- POJ 1006 Biorhythms
- POJ 1007 DNA Sorting
- 标签说明
- POJ 1008 Maya Calendar