这个就是算算数的问题~
题目链接如下:
http://acm.hdu.edu.cn/showproblem.php?pid=1056
代码如下:
// hdu1056.cpp : 定义控制台应用程序的入口点。
//
#include<iostream>
using namespace std;
int judge(double length){
double Numerator = 1;
double Denominator = 2;
int num = 1;
double cur_length = Numerator / Denominator;
while (cur_length < length){
Denominator += 1;
cur_length += (Numerator / Denominator);
num++;
}
return num;
}
int main()
{
double input = 0;
while (1){
scanf("%lf", &input);
if (input - 0 < 0.00001)
{
break;
}
printf("%d card(s)\n",judge(input));
}
return 0;
}