Advertisement
Guest User

UVA - 573

a guest
Mar 26th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. int main()
  5. {
  6.  
  7.     int H,U,D,F;
  8.  
  9.     while( scanf("%d%d%d%d",&H,&U,&D,&F)  && H != 0) {
  10.  
  11.         int i = 1;
  12.         float IH  = U,DC = U,p = (U*F)/100.0;
  13.         if(IH > H) goto OUT;
  14.         else {
  15.                 IH -= D;
  16.             for(i = 2; ;i++){
  17.  
  18.                 DC -= p;
  19.                 if(DC >= 0 && D >= 0)
  20.                     IH += DC;   if(IH > H) break;
  21.                 IH -= D;
  22.                 if( IH < 0) break;
  23.             }
  24.         }
  25.         OUT:
  26.         if(IH > 0) printf("success on day %d\n",i);
  27.         else       printf("failure on day %d\n",i);
  28.     }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement