View Code of Problem 64

#include<stdio.h>
#include<string.h>
#include<math.h>
int bus(int n,int k,int l)
{
	if(n-2<=0||k-k/2+k>l)return k;
	else {return bus(n-1,k-k/2+k,l);}
}

int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c)!=EOF){
		if(a==0&&b==0&&c==0)break;
		printf("%d\n",bus(a,b,c));
	
	}
	
}

Double click to view unformatted code.


Back to problem 64