poj 2586

贪心。

代码:

#include<iostream>
#include<fstream>

using namespace std;

void read(){
//	ifstream cin("in.txt");
	int i,j,k,s,t;
	while(cin>>s>>t)
	{
		t=-t;
		if(s*4+t<0)
		{
			if(10*s+2*t>0)
				cout<<10*s+2*t<<endl;
			else
				cout<<"Deficit"<<endl;
		}
		else
			if(3*s+2*t<0)
			{
				if(8*s+4*t>0)
					cout<<8*s+t*4<<endl;
				else
					cout<<"Deficit"<<endl;
			}
			else
				if(2*s+3*t<0)
				{
					if(6*s+6*t>0)
						cout<<6*s+6*t<<endl;
					else
						cout<<"Deficit"<<endl;
				}
				else
					if(s+4*t<0)
					{
						if(3*s+9*t>0)
							cout<<3*s+9*t<<endl;
						else
							cout<<"Deficit"<<endl;
					}
					else
						cout<<"Deficit"<<endl;
	}
	
}

int main(){
	read();
	return 0;
}

posted on 2011-04-25 15:10  宇宙吾心  阅读(157)  评论(0)    收藏  举报

导航