View Code of Problem 64

#include<stdio.h>
int people(int x) {
	if (x==0)
	{
		return 0;
	}
	else
	{
		return 2*x - x / 2;
	}
}
main() {
	int num, first, large;
	while (scanf("%d %d %d", &num, &first, &large) != EOF) {
		if (num==0&&first==0&&large==0)
		{
			break;
		}
		for (int i = 1; i <= num - 2; i++)
		{
			int count = people(first);
			if (count <= large) {
				first = count;
			}
			else
			{
				break;
			}

		}
		printf("%d\n", first);
	}
}

Double click to view unformatted code.


Back to problem 64