View Code of Problem 87

#include<stdio.h>
main(){
	int a;
	int x,y;
	int min=32768,max=-32768;
	scanf("%d",&a);
	for(x=0;x<=(2/a);x++){
		for(y=0;y<=(4/a);y++){
			if(2*x+4*y==a){
				max=(max>(x+y))?max:(x+y);
				min=(min<(x+y))?min:(x+y);
			}
		}
	}
	if(max==-32768||min==32768){
		printf("0 0");
	}
	printf("%d %d\n",min,max);
}

Double click to view unformatted code.


Back to problem 87