-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuva00573.cpp
More file actions
45 lines (39 loc) · 934 Bytes
/
uva00573.cpp
File metadata and controls
45 lines (39 loc) · 934 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
/* Rishikesh
* UVA 00573 The Snail
* Look at the table about how the snail moves. It has
* to be followed diligently if the test is to be passed.
*/
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<map>
#include<numeric>
#include<algorithm>
using namespace std;
int main() {
#ifdef DEBUGUVA
freopen("test", "r", stdin);
cerr << "This is DEBUG\n";
#endif
double H, U, D, F;
while (cin >> H >> U >> D >> F, H > 0) {
double reduction = F/100 * U;
int d = 1;
double h = U;
bool success = false;
while(h > 0 and h <= H) {
h -= D;
if (h < 0)
break;
U = max(0.0 , U - reduction);
d += 1;
h += U;
}
if (success) {
cout << "success on day " << d << endl;
} else {
cout << "failure on day " << d << endl;
}
}
}