View Code of Problem 87

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a;
	while(cin>>a){
		int x,y,m,min=99999,max=0;
		if(a%2!=0){
			cout<<"0"<<" "<<"0"<<endl;
			break;
		}
			
		for(int x=0;x<=a/2;x++)
		for(int y=0;y<=a/4;y++){
			if(2*x+4*y==a&&x+y<=a/2&&x+y>=a/4){
			 m=x+y;
			if(m<min){
				min=m;
			}
			if(m>max){
				max=m;
			}
	    	}
		}
		cout<<min<<" "<<max<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 87