// UVa 573 - The Snail
#include <iostream>
#include <math.h>
using namespace std;
int main() {
int h, u, d, f;
while (cin >> h >> u >> d >> f && (h != 0 || u != 0 || d != 0 || f != 0)) {
int day = 0;
bool out = false;
double height = 0, ff = f / 100.0, ftg = 0;
do {
day++;
// climb
height += u - ftg * u;
if (height > h) {
out = true;
break;
}
// slide
height -= d;
if (height < 0) {
out = false;
break;
}
// fatigue
ftg += ff;
if (ftg >= 1)
ftg = 1;
} while (height >= 0);
if (out)
cout << "success on day " << day << endl;
else
cout << "failure on day " << day << endl;
}
return 0;
}
Wednesday, June 10, 2015
UVa 573 - The Snail
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment