View Code of Problem 64

#include<iostream>

using namespace std;

int main(){
	
	int n, k, l;
	while(cin>>n>>k>>l){
		if(n==0&&k==0&&l==0)
			break;
		bool flag=true;
		int lev;
		for(int i=0; i<n-2; i++){
			lev = k>>1;
			if(k+lev>l){
				cout<<k<<endl;
				flag=false;
				break;
			}
			k=(k<<1)-lev;	
		}
		if(flag)
			cout<<k<<endl;
	}
	
	return 0;
}

Double click to view unformatted code.


Back to problem 64