-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUVA 573 The Snail.cpp
More file actions
39 lines (37 loc) · 932 Bytes
/
UVA 573 The Snail.cpp
File metadata and controls
39 lines (37 loc) · 932 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
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main()
{
float H, U, D, F;
std::cin >> H;
while (H)
{
std::cin >> U;
std::cin >> D;
std::cin >> F;
int day = 1;
float current_height = 0, loss = U*(F/100);
while (true) {
current_height += U; // climb
if (current_height > H) {
cout << "success on day " << day << std::endl;
break; // OK
}
current_height -= D; // slide
if (current_height < 0) {
cout << "failure on day " << day << std::endl;
break; // FAIL
}
U = (U - loss >= 0) ? U - loss : 0;
day++;
}
std::cin >> H;
}
return 0;
}