View Code of Problem 13

#include<iostream>
using namespace std;
int main(){
	int h,a,b,k;
	int num = 1;    //k   连续k个回合  h是初始血  -a  +b 
	while(scanf("%d%d%d%d",&h,&a,&b,&k)!=EOF){
		for(int i = 0;i<k;i++){
			h = h - a;
			if( h < 1 ) {
				printf("Case #%d: White win",num);
				break;
			}
			h+=b;	
		}
		if(h > 1)printf("Case #%d: Unknow",num);
		cout<<endl;
		num++;
	} 
	return 0;
}

Double click to view unformatted code.


Back to problem 13