-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUVa-573.cpp
More file actions
53 lines (34 loc) · 906 Bytes
/
UVa-573.cpp
File metadata and controls
53 lines (34 loc) · 906 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
46
47
48
49
50
51
52
53
#include <iostream>
#include <cstdio>
using namespace std;
#define FAST cin.tie(0); ios::sync_with_stdio(false); cout.tie(0);
int main () {
FAST
double H, U, D, F;
while (scanf("%lf %lf %lf %lf", &H, &U, &D, &F) != EOF) {
double currHeight = 0;
int day = 1;
if (H == 0)
break;
double factor = U*F/100.0;
int L = U;
while (true) {
currHeight = currHeight + U;
if (currHeight > H)
break;
currHeight -= D;
if (U > 0)
U -= factor;
if (currHeight < 0)
break;
day++;
}
if (currHeight >= H) {
printf("success on day %d\n", day);
}
else {
printf("failure on day %d\n", day);
}
}
return 0;
}