Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- int main()
- {
- int H,U,D,F;
- while( scanf("%d%d%d%d",&H,&U,&D,&F) && H != 0) {
- int i = 1;
- float IH = U,DC = U,p = (U*F)/100.0;
- if(IH > H) goto OUT;
- else {
- IH -= D;
- for(i = 2; ;i++){
- DC -= p;
- if(DC >= 0 && D >= 0)
- IH += DC; if(IH > H) break;
- IH -= D;
- if( IH < 0) break;
- }
- }
- OUT:
- if(IH > 0) printf("success on day %d\n",i);
- else printf("failure on day %d\n",i);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement