View Code of Problem 13

#include<stdio.h>
void main(){
	int h,a,b,k,i,t,flag;
	t=1;
	while(scanf("%d%d%d%d",&h,&a,&b,&k)!=EOF){
		flag=1;
		for(i=1;i<=k;i++){
			h=h-a;
			if(h<1){
				printf("Case #%d: White win\n",t);
				flag=0;
				break;
			}
			h=h+b;
		}
		h=h+b;
		if(flag==1)
			printf("Case #%d: Unknow\n",t);
		t++;
	}
}

Double click to view unformatted code.


Back to problem 13