View Code of Problem 13

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
	
		int h,a,b,k;
		int count=1;
	
		while(sc.hasNext()) {
			int flag=1;
			h=sc.nextInt();
			a=sc.nextInt();
			b=sc.nextInt();
			k=sc.nextInt();
			int hs=h;	
			for(int i=0;i<k;i++) {
					h-=a;
					if(h<1) {
						System.out.println("Case #"+count+": White win");
						flag=0;
						break;
					}
					h+=b;
						
			}
			h+=b;
			if(flag==1) {
				if(hs<=h) {
							System.out.println("Case #"+count+": Unknow");
					}
				else {
					System.out.println("Case #"+count+": White win");
				}
			}
			count++;	
			
		}
		sc.close();
	}
	
}

Double click to view unformatted code.


Back to problem 13