View Code of Problem 64

#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
using namespace std;

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

Double click to view unformatted code.


Back to problem 64