View Code of Problem 87

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

Double click to view unformatted code.


Back to problem 87