View Code of Problem 64

#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
	int n,k,l,i,a;
	while(scanf("%d %d %d",&n,&k,&l))
	{
		if(n==0&&k==0&&l==0)
		   break;
		for(i=0;i<n-2;i++)
		{
			a=k;
			k=k-a/2+a;
			if(k>l)
			{
				k=k+a/2-a;
				break;
			}
		}
		printf("%d\n",k);
	}
	
	return 0;
}

Double click to view unformatted code.


Back to problem 64