解题思路:
1.此题考察循环结构
坑点:1.输入0 0 0应输出0
2.如果h=10,x=11,y=12时,应输出1
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long h,x,y;//定义x,y,h
cin>>h>>x>>y;
long long hi=0,i;//hi为h的时时变化 ,i为时间
if(h==0&&x==0&&y==0){cout<<0;return 0;}//如果输入0 0 0,输出0
if(x<=y&&x<h){cout<<"It can't get out!";return 0;}//如果x<=y与x<h
for(i=1;i<h;i++)//求解
{
if(hi+x>=h)
break;
else hi=hi+x-y;
}
cout<<i;//输出
return 0;
}