【每日刷题】 PAT 基础习题集 7-17 爬动的蠕虫 (15 分)
题目描述:
代码如下:
//7-17
#include <stdio.h>
int main ( void )
{
int n, u, d;
scanf( "%d%d%d", &n, &u, &d );
int s = 0, t = 0;
while( s < n ){
if( s + u < n ){
t += 2;
s += ( u - d );
}
else{
t += 1;
s += u;
}
}
printf( "%d", t );
return 0;
}