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

Re:思路较简单的程序(可能比较笨的办法).做不出的可以参考参考.

Posted by whd0810 at 2008-05-16 20:38:42 on Problem 1017
In Reply To:思路较简单的程序(可能比较笨的办法).做不出的可以参考参考. Posted by:poiulkj at 2007-05-14 22:20:29
> 从6*6开始往下推.有多少个6*6就至少需要多少个packets.有多少个5*5也至少需要多少个packets.但空出来的地主可以放1*1.有多少个4*4也至少需要多少个packets.但空出来的地主可以放2*2,如果还有空,就可以放1*1,当然,前提时这时还有2*2或1*1.就这样推下去.思路简单,程序也容易实现.做不出的可以试试.
> 
> #include<iostream.h>
> void main()
> {
> 	int a[7],sum;
> 	cin>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6];
> 	while(a[1]!=0||a[2]!=0||a[3]!=0||a[4]!=0||a[5]!=0||a[6]!=0)
>     {
> 	sum=0;
> 	if(a[6]!=0) sum+=a[6];
> 	if(a[5]!=0) 
> 	{ sum+=a[5];
> 	  if(a[1]>0)
> 	  a[1]=a[1]-11*a[5];
> 	  if(a[1]<0) a[1]=0;
> 	}
> 	if(a[4]!=0)
> 	{ sum+=a[4];
> 	  if(a[1]>0)
> 	  { if(a[4]*5-a[2]>0)
> 	       a[1]=a[1]-4*(a[4]*5-a[2]);
> 	    if(a[1]<0) a[1]=0;
> 	  }
> 	  if(a[2]>0)
> 	  a[2]=a[2]-5*a[4];
> 	  if(a[2]<0) a[2]=0;
> 	}
> 	if(a[3]!=0)
> 	{  sum+=a[3]/4;
> 	   if(a[3]%4!=0) sum++;
> 	   if(a[1]>0)
> 		   if(a[3]%4!=0)
> 		   { if(a[3]%4==1)
>                 if(a[2]<=5) a[1]=a[1]-27-a[2]*4;
> 				else a[1]=a[1]-7;
> 			if(a[3]%4==2)
>                 if(a[2]<=3) a[1]=a[1]-18-a[2]*4;
> 				else a[1]=a[1]-6;
> 			if(a[3]%4==3)
>                 if(a[2]<=1) a[1]=a[1]-9-a[2]*4;
> 				else a[1]=a[1]-5;
> 		   }
>        if(a[1]<0) a[1]=0;
> 	   if(a[2]>0)
> 	     if(a[3]%4!=0)
> 		 { if(a[3]%4==1)
> 		      a[2]=a[2]-5;
> 		   else if(a[3]%4==2)
> 			       a[2]=a[2]-3;
> 		   else   
> 			   a[2]=a[2]-1;
> 		 }
> 	   if(a[2]<0) a[2]=0;
> 	 }
> 	 if(a[2]!=0)
> 	 { sum+=a[2]/9;
> 	   if(a[2]%9!=0) sum++;
> 	   if(a[1]>0)
> 	      if(a[2]%9!=0)
> 		     a[1]=a[1]-36+4*(a[2]%9);
> 	   if(a[1]<0) a[1]=0;
> 	 }
> 	 if(a[1]!=0)
> 	 { sum+=a[1]/36;
> 	   if(a[1]%36!=0) sum++;
> 	 }
> 	 cout<<sum<<endl;
> 	 cin>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6];
> 	}
> }

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