题意:一只蚂蚁在一个深度为n的洞穴了,现知蚂蚁每分钟可以向上爬u,但爪巴了一分钟后就的休息一分钟,在这一分钟内它会向下滑落d,问要多久蚂蚁可以爬出洞穴
经典小学(雾)数学题,模拟一下就完事
AC代码:
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main() {
int n, u, d;
while (scanf("%d %d %d", &n, &u,&d) != EOF) {
if (u ==0&& d==0&& n == 0) {
break;
}
int time = 0;
int now = 0;
while (now<n) {
time++;
now += u;
if (now >= n) break;
time++;
now -= d;
}
printf("%d\n", time);
}
}