/* coder: ACboy date: 2010-3-3 result: AC description: UVa 573 - The Snail */ #include <iostream> using namespace std; int main() { double H, D, U, F; #ifndef ONLINE_JUDGE freopen("573.txt", "r", stdin); #endif while (cin >> H >> D >> U >> F) { if (H == 0) break; double k = F / 100; double climbed = 0; double temp = D; int day = 0; int ok = 0; // 题目中说明只有当蜗牛爬行高度超高墙的高度或蜗牛的爬行高度小于零时停止计算天数 //(In other words, the snail's height will exceed the height of the well or become negative.) while (climbed >= 0) { day++; climbed += D; if (climbed > H) { ok = 1; break; } D = D - temp * k; // 当蜗牛的爬行速度降为零一下时,蜗牛的爬行速度就为零。题目中的描述如下。 // The snail never climbs a negative distance. If the fatigue factor drops // the snail's climbing distance below zero, the snail does not climb at all that day. if (D < 0) D = 0; climbed -= U; } if (ok) { cout << "success on day " << day << endl; } else { cout << "failure on day "<< day << endl; } } return 0; }