View Code
1 /* 2 蜗牛从井底爬出来的时间,模拟 3 */ 4 #include<stdio.h> 5 #include<stdlib.h> 6 #include<string.h> 7 #include<iostream> 8 #include<algorithm> 9 #include<queue> 10 #include<map> 11 #include<math.h> 12 using namespace std; 13 const int maxn = 1005; 14 const int inf = 0x7fffffff; 15 int main(){ 16 int s,u,d; 17 while( scanf("%d%d%d",&s,&u,&d)==3 ,s+u+d ){ 18 int ans=0; 19 while( 1 ){ 20 s-=u; 21 ans++; 22 if( s>0 ) { 23 s+=d; 24 ans++; 25 } 26 else break; 27 } 28 printf("%d\n",ans); 29 } 30 return 0; 31 }
水~~~