-
Notifications
You must be signed in to change notification settings - Fork 0
/
uva00573.cpp
44 lines (37 loc) · 1.09 KB
/
uva00573.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// uva00573.cpp
//
//
// Created by 赵洋 on 15/9/16.
//
//
#include <iostream>
using namespace std;
int main(){
double height, up, down, fatigue;
double initial_height, distance_climbed, height_after_climb, height_after_slide;
double reduce;
while(cin >> height >> up >> down >> fatigue, height != 0){
initial_height = 0;
distance_climbed = up;
reduce = up * fatigue / 100;
for(int i = 1; ; ++i){
height_after_climb = initial_height + distance_climbed;
if(height_after_climb > height){
cout << "success on day " << i << endl;
break;
}
height_after_slide = height_after_climb - down;
if(height_after_slide < 0){
cout << "failure on day " << i << endl;
break;
}
distance_climbed -= reduce;
if(distance_climbed < 0){
distance_climbed = 0.0;
}
initial_height = height_after_slide;
}
}
return 0;
}