View Code of Problem 13

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
    int h,a,b,k,r,n=1;
    while(~scanf("%d%d%d%d",&h,&a,&b,&k)){
        srand((unsigned)time(NULL));
        r=rand()%k+1;
        while(k--){
            if(r==k){
                continue;
            }
            else {
                h-=a;
                if(h<1){
                    break;
                }
                h+=b;
            }
        }
        if(h<1){
            printf("Case #%d: White win\n",n);
        }
        else{
            printf("Case #%d: Unknow\n",n);
        }
        n++;
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 13