View Code of Problem 13

#include<bits/stdc++.h>
using namespace std;
int main() {
	int h,a,b,k,count=1;
	while(cin>>h>>a>>b>>k) {
		cout<<"Case #"<<count++<<": ";
		if(a-b<=0&&h-a>=1) {//黑龙不可能死 
			cout<<"Unknow"<<endl;
		}else {//黑龙可能死 
			int flag=1,t=h;
			for(int i=1; i<=k; i++) {
				h-=a;
				if(h<1) {
					flag=0;//表示黑龙死亡
					break; 
				}
				h+=b;
			}
			if(h+b<t) flag=0;//回合结束 
			if(flag) cout<<"Unknow"<<endl;
			else cout<<"White win"<<endl;
		}
	}
}

Double click to view unformatted code.


Back to problem 13