View Code of Problem 87

#include <stdio.h>
int main()
{
	int x,y,a,foot;
	int min,max=0;
	int state=0;
    scanf("%d",&a);
	min=a;
	for(x=0;x<=a/2;x++)
		for(y=0;y<=a/4;y++)
		{
			foot=x*2+y*4;
			if(foot==a)
			{
				if(x+y>max) max=x+y;
				if(x+y<min) min=x+y;
				state=1;
				
			}
		
		}
		if(state==0)
		{
			min=0;
			max=0;
		}

	printf("%d %d\n",min,max);
		return 0;
}

Double click to view unformatted code.


Back to problem 87