View Code of Problem 87

#include <stdio.h>
int main()
{
	int a;
	scanf("%d",&a);
	int i,j,max,min;
	min = 9999;
	max = 0;
	for(i = 0;i <= a/2;i ++){
		for(j = 0;j <= a/4;j ++){
			if(i*2+j*4 == a){
				if(i+j >= max){
					max = i+j;
				}
				if(i+j <= min){
					min = i+j;
				}
			}
		}
	}
	if(min == 9999||max == 0){
		printf("0 0\n");
	}
	else{
		printf("%d %d\n",min,max);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 87