Advertisement
erfanul007

UVa 573

Nov 24th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. double h,u,d,f,p,i,t;
  5. while(1){
  6. scanf("%lf %lf %lf %lf",&h,&u,&d,&f);
  7. if(h==0)
  8. break;
  9. p=u*(f/100);
  10. i=0;
  11. t=0;
  12. while(1){
  13. i=i+1;
  14. t=t+u;
  15. u=u-p;
  16. if(u<0)
  17. u=0;
  18. if(t>h){
  19. printf("success on day %.0lf\n",i);
  20. break;
  21. }
  22. t=t-d;
  23. if(t<0){
  24. printf("failure on day %.0lf\n",i);
  25. break;
  26. }
  27. }
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement