View Code of Problem 64

#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
    int n,k,l;
    while(cin>>n>>k>>l)
    {
        if(n==0&&k==0&&l==0)
            break;
        int ans=0;
        for(int i=1;i<n-1;i++)
        {
            if(k-k/2+k>=l)
            {
                ans=k;
                break;
            }
            else
            {
                k=k-k/2+k;
                ans=k;
            }
        }
        cout<<ans<<endl;
    }
}

Double click to view unformatted code.


Back to problem 64