View Code of Problem 13


import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count=1;
        while (scanner.hasNext()) {
            int h = scanner.nextInt();
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int k = scanner.nextInt();
            int temp = h;
            boolean flag = false;
            for (int i = 0; i < k; i++) {
                temp = temp - a;
                if (temp < 0) {
                    flag = true;
                    break;
                }
                temp = temp + b;
            }
            temp = temp + b;
            if (temp < h) {
                flag = true;
            }
            if (flag) {
                System.out.printf("Case #%d: White win\n",count);
            }else {
                System.out.printf("Case #%d: Unknow\n",count);
            }
            count++;
        }
    }
}

Double click to view unformatted code.


Back to problem 13