//1_4_1: Hangover 卡片伸向桌子外 POJ1003 ZOJ1045
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn = 300;
double len[maxn];
int main()
{
int i,n = 1;
double length;
len[n] = 0.5;
while(len[n] <= 5.2)
{
++n;
len[n] = len[n - 1] + 1 / (double)(n + 1);
}
while(1)
{
scanf("%lf",&length);
if(length == 0.0)
break;
for(i = 0;i < n;i ++)
if(len[i] >= length)
{
printf("%d card(s)\n",i);
break;
}
}
return 0;
}
/*测试结果:通过POJ1003 ZOJ1045检测
1.00
3 card(s)
3.71
61 card(s)
0.04
1 card(s)
5.19
273 card(s)
0.00
请按任意键继续. . .
*/
POJ1003 ZOJ1045 Hangover
最新推荐文章于 2017-06-16 17:24:57 发布