View Code of Problem 13

#include<iostream>
using namespace std;
int main()
{
    int h,a,b,k,Case=0;
    while(cin>>h>>a>>b>>k)
    {
        Case++;
        int i=k;
        int j=h;
        while(1)
        {
            k--;
            h=h-a;
            if(h>0)
                h=h+b;
            else {cout<<"Case #"<<Case<<": White win"<<endl;break;}
            if(k==0)
            {
               h=h+b;
               k=k+i;
            }
            if(j<=h){cout<<"Case #"<<Case<<": Unknow"<<endl;break;}
        }
    }
    return 0;
}

Double click to view unformatted code.


Back to problem 13