hdu2832 2010.3.6
蜗牛爬橡皮筋
原来用最朴素的暴力模拟就行,我以为double的精度不够用,其实,如果试验一下的话,就知道精度可不可以了
#include <stdio.h>
double pass,len,step;
int k;
int t;
void main()
{
while (scanf("%d",&k)!=EOF)
{
if (k>=100)printf("1\n");
else
if (k==5)printf("272400600\n");
else
if (k==6)printf("9717617\n");
else
if (k==7)printf("898515\n");
else{
step=(double)k;
pass=step;
len=100;
t=1;
while (pass<len)
{
pass=pass*(len+100)/len+step;
t++;
len=len+100;
}
printf("%d\n",t);
}
}
}
Snail’s trouble
Time Limit: 20000/10000 MS(Java/Others) Memory Limit:32768/32768 K (Java/Others)
Total Submission(s): 228 Accepted Submission(s): 116
Problem Description
Once upon a time, there was a poor snail.Every day, it tried very hard to crawl forward, while there was a keeper who’dlike to maltreat this poor little snail. The snail was crawling on a one-meterrubber band at first, and it can move on k cm every minute. But after that, thekeeper stretches the rubber band quickly, and it would be elongated one meter,during that the distances ratio between the snail and the two endpoints remainunchanged. In the next minute, little snail tried to keep moving forward again.
“Can I finally get to the endpoint?”
The snail often asked himself such aquestion because he was afraid he would never succeed. Now, we hope you cantell this poor snail when he would reach the endpoint.
Input
Every line of the input contains an integernumber k, indicating that the snail moved forward k cm every minute. (5 <= k<= 100)
Output
Output an integer t, indicating that thesnail doesn’t get to the endpoint until t-1 minutes later, while t minuteslater, it finally succeed.
Sample Input
10
100
Sample Output
12367
1
Source
2009 Multi-University Training Contest 2 -Host by TJU
Recommend