Saleh127

Untitled

Apr 22nd, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. double a,b,c,j,k,h,u,d,f;
  6. while(scanf("%lf %lf %lf %lf",&h,&u,&d,&f)==4)
  7. {
  8. int i,l;
  9. i=1;
  10. a=0;
  11. c=(f*u)/100;
  12. if(h==0)
  13. break;
  14. for( ; ; )
  15. {
  16. a+=u;
  17. if(u>0) u-=c;
  18.  
  19. if(a>h)
  20. {
  21. break;
  22. }
  23. a-=d;
  24.  
  25. if(a<0)
  26. {
  27. break;
  28. }
  29. i++;
  30. }
  31. if(a<0)
  32. printf("failure on day %d\n",i);
  33. else
  34. {
  35. printf("success on day %d\n",i);
  36. }
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment