小蜗牛

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’d like to maltreat this poor little snail. The snail was crawling on a one-meter rubber band at first, and it can move on k cm every minute. But after that, the keeper stretches the rubber band quickly, and it would be elongated one meter, during that the distances ratio between the snail and the two endpoints remain unchanged. 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 a question because he was afraid he would never succeed. Now, we hope you can tell this poor snail when he would reach the endpoint.

Input
Every line of the input contains an integer number k, indicating that the snail moved forward k cm every minute. (5 <= k <= 100)

Output
Output an integer t, indicating that the snail doesn’t get to the endpoint until t-1 minutes later, while t minutes later, it finally succeed.

Sample Input
10
100

Sample Output
12367
1

#include <cstdio>
#include <iostream>
using namespace std;
int n,ans[109];
void init()
{
    ans[5]=272400600;
    ans[6]=9717617;
    ans[7]=898515;
    ans[8]=150661;
    ans[9]=37568;
    for(int i=10; i<=100; i++)
    {
        double t=0;
        double p=1;
        while(t<100)
        {
            t+=i/p++;
        }
        ans[i]=p-1;
    }
}
int main()
{
    init();
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",ans[n]);
    }
    return 0;
}

Reflect:
1,由于没爬完一次橡皮筋都会被拉伸以一次,我们可以想象在第一次爬之前就被拉伸了一次,所以相当于只爬了i/p cm;
2,由于前面几个数较大,计算所需时间较长,所以,将其直接写出,其他的打表;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值