View Code of Problem 13

#include<iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
#pragma warning(disable:4996)


int main() {
	int h, a, b, k;
	int fg = 0;
	int count = 1;
	while (scanf("%d %d %d %d", &h, &a, &b, &k) != EOF) {
		fg = h;
		for (int i = 1;; i++) {			
			if (h >= fg&&i>=k+1) {
				printf("Case #%d: Unknow\n", count);
				break;
			}
			if (i % k  != 0) {
				h = h - a;
				if (h < 1) {
					printf("Case #%d: While win\n", count);
					break;					
				}	
				h = h + b;
			}
			else		{
				h = h + b;
			}
		}
		count++;
	}
	return 0;
}	

Double click to view unformatted code.


Back to problem 13