View Code of Problem 13

#include <stdio.h>
#include <stdlib.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
int main()
{
	int h, a, b, k, i, j, first;
	j = 0;
	while (scanf("%d%d%d%d",&h,&a,&b,&k)!=EOF)
	{
		first=h;
		j++;
		for (i = 0; i < k; i++)
		{
			h -= a;
			if(h<1)
            {
                break;
            }
			h += b;
		}
		if(i==k)
		h+=b;
		if (h >= first)
			printf("Case #%d: Unknow\n", j);
		else printf("Case #%d: White win\n", j);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 13