#include<stdio.h>
main(){
int N,U,D,h=0,t=0;
scanf("%d%d%d",&N,&U,&D);
while(h<N){
h=h+U;
t++;
if(h>=N){
break;
}else{
h=h-D;
t++;
}
}
printf("%d",t);
}
PTA基础编程题目集7-17 爬动的蠕虫
最新推荐文章于 2023-01-02 17:08:26 发布
#include<stdio.h>
main(){
int N,U,D,h=0,t=0;
scanf("%d%d%d",&N,&U,&D);
while(h<N){
h=h+U;
t++;
if(h>=N){
break;
}else{
h=h-D;
t++;
}
}
printf("%d",t);
}