#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int h, u, d, f;
int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
while(scanf("%d%d%d%d", &h, &u, &d, &f) == 4 && h) {
h *= 100; u *= 100; d *= 100;
int t = f * u / 100; //速度减少量
int s = 0; //高度
int n = 0; //天数
int v = u; //速度
while(1) {
n ++;
s += v;
if(s > h) {
printf("success on day %d\n", n);
break;
}
v -= t;
if(v < 0) v = 0;
s -= d;
if(s < 0) {
printf("failure on day %d\n", n);
break;
}
}
}
return 0;
}
UVa 573 - The Snail
最新推荐文章于 2026-06-23 08:51:07 发布
本文通过一个具体的C++程序示例,展示了如何解决一个经典的攀登问题。该程序利用算法逐步模拟攀登过程,判断是否能在指定条件下成功到达目标高度。通过调整每日上升和下降的高度,以及考虑速度衰减因素,来确定攀登的最终结果。

414

被折叠的 条评论
为什么被折叠?



