View Code of Problem 13

#include "stdio.h"

void main()
{
	int h,a,b,k;
	int i;
	int chushi;
	int x;
	for(x=0;scanf("%d%d%d%d",&h,&a,&b,&k)!=EOF;x++)
	{
		chushi=h;
		for(i=1;;i++)
		{
		//	printf("%d\n",i%k);
			if(i%(k+1)==0)
			{
				h=h+b;
				if(h>=chushi)
				{
					printf("Case #%d: Unknow\n",x+1);	
					break;
				}
			}
			else
			{
				h=h-a;
				if(h<1)
				{
					printf("Case #%d: White win\n",x+1);
					break;
				}
				h=h+b;
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 13