View Code of Problem 13

#include<stdio.h>
#define N 100
int main()
{
	int h,a,b,k,n=1,i,h0;
	int rest;
	while(n<=N)
	{
		scanf("%d %d %d %d",&h,&a,&b,&k);
		h0=h;
		for(rest=1;rest<=k+1;rest++)
		{
			i = 1,h=h0;
			while(i<=k)
			{
				if(i!=rest) h-=a;
				if(h<1) break;
				h+=b;
				i++;
			}
			if(h<1) break;
		}
		if(i>k) printf("Case #%d: Unknown",n);
		else printf("Case #%d: White win",n);
		printf("\n");
		n++;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 13