hdu 2832(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2832

坑爹的精度损失。。。。orz。。。。

View Code
 1 #define _CRT_SECURE_NO_WARNINGS
 2 #include<iostream>
 3 #include<cstdio>
 4 #include<cstring>
 5 #include<cmath>
 6 using namespace std;
 7 
 8 
 9 int main(){
10     double n;
11     while(~scanf("%lf",&n)){
12         if(n==5){printf("272400600\n");continue;}
13         else if(n==6){printf("9717617\n");continue;}
14         double len=n;//转化为小数就有精度损失了。。。orz
15         double dist=0;
16         int day=0;
17         double l=100;
18         while(1){
19             dist+=len;
20             day++;
21             if(dist>=l)break;
22             dist=dist/l*(l+100);
23             l+=100;
24         }
25         printf("%d\n",day);
26     }
27     return 0;
28 }

 

posted @ 2013-04-26 13:01  ihge2k  阅读(194)  评论(0编辑  收藏  举报