View Code of Problem 13

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

Double click to view unformatted code.


Back to problem 13