HU 1302-The Snail
2968 ワード
テーマリンク:http://acm.hdu.edu.cn/showproblem.php?pid=1302
#include
using namespace std;
// : F%,
int main() {
double h, u, d, f, first;
while (cin >> h >> u >> d >> f, h) {
double sum = 0;
int day = 0, flag = 1;
first = u * f * 0.01;
//The distance lost to fatigue is always 10% of
//the first day's climbing distance
sum += u;
day ++;
while (sum <= h && flag) {
sum -= d;
if (sum < 0) {
flag = 0;
cout << "failure on day " << day << endl;
break;
}
u -= first;
// f%
sum += u;
day++;
}
if (flag)
cout << "success on day " << day << endl;
}
return 0;
}