Advertisement
ahmad_zizo

UVA

Jan 29th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6. int x[4];
  7. int i;
  8. float C;
  9. scanf("%d %d %d %d",&x[0],&x[1],&x[2],&x[3]);
  10. while(x[0]!=0)
  11. {
  12. C=0.0;
  13. for(i=1; C<=x[0] && C>=0; i++)
  14. {
  15. C=C+x[1] - 1.0*((i-1)*x[1]*x[3]/100);
  16. if(C<x[0] && C>=0)
  17. C=C-x[2];
  18. }
  19. if(C<0)
  20. printf("failure on day %d\n",i-1);
  21. else
  22. printf("success on day %d\n",i-1);
  23.  
  24. scanf("%d %d %d %d",&x[0],&x[1],&x[2],&x[3]);
  25. }
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement