View Code of Problem 64

#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;
int kk(int ki){
	return ki=ki-ki/2+ki; 
}
int main(){
	int n,k,l;
	while(1){
		cin>>n>>k>>l;
		if(n==0&&k==0&&l==0)
			break;
		int updown=n-2;//去掉头尾
		for(int i=0;i<updown;i++){
			if(kk(k)<=l){
				k=kk(k);
			}
			else{
				break;
			}
		}
		cout<<k<<endl;
	}
	
}

Double click to view unformatted code.


Back to problem 64