hdu1408

http://acm.hdu.edu.cn/showproblem.php?pid=1408

精度问题

ContractedBlock.gif ExpandedBlockStart.gif View Code
 
    
#include " iostream "
using namespace std;
int main()
{
double v,d;
while (cin >> v >> d)
{
int l = v / d; // l为所滴的滴数
if (l != v / d) l ++ ; // +1表示最后一滴小于d,也算成一滴

double sum = 0 ;
int t = 0 ; // 记录间隔数
int i = 1 ;
while (sum < l) // 已有的滴数和总的滴数比较
{
sum
+= i;
t
++ ;
i
++ ;
}
cout
<< t + l - 1 << endl;
}
return 0 ;
}

转载于:https://www.cnblogs.com/FCWORLD/archive/2011/04/04/2005024.html

猜你喜欢

转载自blog.csdn.net/weixin_33724059/article/details/94156059