View Code of Problem 13

#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,h,k,op = 1,t;
	//h是黑龙血量  是k次攻击后  a黑龙血量降低  b回复血量 
	while(scanf("%d%d",&h,&a)!=EOF){
		scanf("%d%d",&b,&k);
		t = h;  //存着最初血量 
		int f = 0,i;
		for(i = 0;i < k;i++){
			h = h - a;
			if(h < 1){
				f = 1;
				break;	
			}
			h = h + b;
		}
		//正常退出
		if(i==k)h = h + b;
		if(t < h)f = 0; 
		//血越打越多,肯定Un了 
		if(!f)printf("Case #%d: Unknow",op);
		else printf("Case #%d: White win",op);
		cout<<endl; 
		op++;
		 
	}
	
	
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 13