#include<iostream> #include<cstdio> #include<cmath> #define db(a) cout << #a << " = " << a << endl; using namespace std; int main(){ double h, d, u, f; int days = 0; while(cin >> h >> u >> d >> f && h != 0){ days = 0; double climbed = 0; double fac = (f * u) / 100.; while(true){ days++; if(u >= 0) climbed += u; u -= fac; if(climbed > h) break; climbed -= d; if(climbed < 0) break; } if(climbed > h) printf("success on day %d\n", days); else printf("failure on day %d\n", days); } return 0; }
No hay comentarios:
Publicar un comentario