很简单,不过还是wa了几次,才做对
#include<iostream> using namespace std; int main(){ int h,speed,slide,per; while(cin>>h>>speed>>slide>>per){ if(!h&&!speed&&!slide&&!per) break; h*=100; speed*=100; slide*=100; int d=speed*per/100; int height=0; for(int i=0;;i++){ if(speed<=0) speed=0; height+=speed; if(height>h){ cout<<"success on day "<<i+1<<endl; break; } height-=slide; if(height<0){ cout<<"failure on day "<<i+1<<endl; break; } speed-=d; } } }