首页 > 其他 > 详细

uva 573 - The Snail

时间:2014-01-14 21:43:29      阅读:533      评论:0      收藏:0      [点我收藏+]

很简单,不过还是wa了几次,才做对

bubuko.com,布布扣
#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;
        }
    }
}
bubuko.com,布布扣

uva 573 - The Snail

原文:http://www.cnblogs.com/royjwy/p/3513715.html

(0)
(0)
   
举报
评论 一句话评论(0
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!