-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVA573.cpp
More file actions
45 lines (40 loc) · 902 Bytes
/
UVA573.cpp
File metadata and controls
45 lines (40 loc) · 902 Bytes
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
45
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int days = 1;
bool checkexceeds(double& distance, double& h){
if(distance <0){
printf("failure on day %d\n", days);
return true;
}
else if(distance > h){
printf("success on day %d\n", days);
return true;
}
return false;
}
int main(){
double h, u , d, f;
while(true){
double distance =0;
days = 1;
scanf("%lf %lf %lf %lf", &h, &u, &d, &f);
if(h <=0){
break;
}
f = u*f/100.0;
//cout << f << endl;
for(days;true; days++){
distance += u;
if (checkexceeds(distance, h)){
break;
}
distance -= d;
if(checkexceeds(distance, h)){
break;
}
u = fmax(u-f, 0);
}
}
return 0;
}