Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

呵呵 经典的贪心!!! 建议再考虑一下有没有什么漏掉的情况!!!

Posted by rruucc at 2004-02-09 22:39:54 on Problem 1017
In Reply To:help!!! Posted by:fdfzq at 2004-02-09 13:28:52
> #include<iostream.h>
> int a[2001][7];
> int chuli(int i)
> {
> 	int geshu[7];
> 	int sheng[6];
> 	int yu4=0,j;
> 	int ans=0;
> 	geshu[6]=a[i][6];
> 	geshu[5]=a[i][5];
> 	if(geshu[5]*11>=a[i][1])
> 		sheng[1]=0;
> 	else
> 		sheng[1]=a[i][1]-11*geshu[5];
>     geshu[4]=a[i][4];
> 	if(geshu[4]*5>a[i][2])
> 	{
> 		sheng[2]=0;
> 		yu4=geshu[4]*5-a[i][2];
> 	}
> 	else
> 		sheng[2]=a[i][2]-5*geshu[4];
> 	if(sheng[2]<0)
> 		sheng[2]=0;
> 	sheng[3]=a[i][3]%4;
> 	if(sheng[3]==0)
> 		geshu[3]=a[i][3]/4;
> 	else
> 		geshu[3]=a[i][3]/4+1;
> 	if((sheng[1]>0)&&(sheng[2]==0))
> 		sheng[1]=sheng[1]-4*yu4;
> 	if(sheng[1]<=0)
> 		sheng[1]=0;
> 	if(sheng[3]==1)
> 	{
> 		if(sheng[2]>=5)
> 		{
> 			sheng[2]=sheng[2]-5;
> 			sheng[1]=sheng[1]-7;
> 			if(sheng[1]<0)
> 				sheng[1]=0;
> 		}
> 		else
> 		{
> 			sheng[1]=sheng[1]-(5-sheng[2])*4-7;
> 				if(sheng[1]<0)
> 					sheng[1]=0;
>              sheng[2]=0;
> 		}
> 		    
> 	}
> 	if(sheng[3]==2)
> 	{
> 		if(sheng[2]>=3)
> 		{
> 			sheng[2]=sheng[2]-3;
> 			sheng[1]=sheng[1]-6;
> 			if(sheng[1]<0)
> 				sheng[1]=0;
> 		}
> 		else
> 		{
> 			sheng[1]=sheng[1]-(3-sheng[2])*4-6;
> 			if(sheng[1]<0)
> 				sheng[1]=0;
> 			sheng[2]=0;
> 		}
> 
> 	}
> 	if(sheng[3]==3)
> 	{
> 		if(sheng[2]>=1)
> 		{
> 			sheng[2]=sheng[2]-1;
> 			sheng[1]=sheng[1]-5;
> 			if(sheng[1]<0)
> 				sheng[1]=0;
> 		}
> 		else
> 		{
> 			sheng[1]=sheng[1]-9;
> 			if(sheng[1]<0)
> 				sheng[1]=0;
> 		}
> 	}
> 	if((sheng[1]>0)||(sheng[2]>0))
> 	{
> 		if((sheng[1]+sheng[2]*4)%36==0)
> 			geshu[2]=(sheng[1]+sheng[2]*4)/36;
> 		else
> 			geshu[2]=(sheng[1]+sheng[2]*4)/36+1;
> 	}
> 	for(j=6;j>=2;j--)
> 	{
> 		if(geshu[j]>0)
> 			ans=ans+geshu[j];
> 	}
> 	return ans;
> }
> void main()
> {
> 	int i,j;
> 	int n=0;
> 	for(i=1;i<=2000;i++)
> 	{
> 		n++;
> 		for(j=1;j<=6;j++)
> 		cin>>a[i][j];
> 		if((a[i][1]==0)&&(a[i][2]==0)&&(a[i][3]==0)&&
> 			(a[i][4]==0)&&(a[i][5]==0)&&(a[i][6]==0))
> 			break;
> 	}
> 	n--;
> 	for(j=1;j<=n;j++)
> 		cout<<chuli(j)<<endl;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator