HDU 2832 Snail’s trouble

Description

一只蜗牛在一根绳子上爬啊爬,k cm/min,然后绳子它每爬完,就延长1m,不过蜗牛的位置比例不变。然后问多久能爬到

Alogrithm

模拟蜗牛爬,绳子延长就OK了

Code

#include <iostream>
using namespace std;

int main()
{
  int k;
  while (cin >> k)
  {
    double x = 0;
    double l = 100;
    int t = 0;
    for (;;)
    {
      t++;
      x += k;
      if (x >= l) break;
      x /= l;
      l += 100;
      x *= l;
    }
    cout << t << endl;
  }
  return 0;
}

你可能感兴趣的:(HDU 2832 Snail’s trouble)