Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define endl '\n'
- #define sz(x) int(x.size())
- #define all(x) x.begin(), x.end()
- int main() {
- ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
- double h, u, d, f;
- while (scanf("%lf %lf %lf %lf", &h, &u, &d, &f), h) {
- int day = 1;
- double curr_pos = 0;
- bool can = true;
- f = u * (f / 100);
- for (; day; day++) {
- curr_pos += u;
- if (curr_pos > h) break;
- u = max(double(0), u - f);
- curr_pos -= d;
- if (curr_pos < 0) {
- can = false;
- break;
- }
- }
- cout << (can ? "success" : "failure") << " on day " << day << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement