View Code of Problem 13

#include<iostream>

using namespace std;

int main() {
	int h, a, b, k,hp;
	int num = 1;
	while (scanf("%d%d%d%d",&h,&a,&b,&k)!= EOF) {
		int flag = 0;
		hp = h;
		if (a >= h) {
			flag = 1;
		}
		else {
			while (hp<=h) {		
				for (int i = 0;i < k;i++) {
					hp -= a;
					if (hp < 1) {
						flag = 1;	
						break;
					}
					hp += b;
				}
				hp += b;
				if (flag == 1 || hp == h)
					break;		
			}
		}
		if (flag == 0) {
			cout << "case #" << num << ": Unknow" << endl;
		}
		else {
			cout << "case #" << num << ": White win" << endl;
		}
		num++;		
	}
	return 0;
}
/*
Main.c:1:19: fatal error: iostream: No such file or directory
 #include<iostream>
                   ^
compilation terminated.
*/

Double click to view unformatted code.


Back to problem 13