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 madrishin at 2012-05-18 21:29:05 on Problem 1017
#include <cstdio>
#include<cstring>
int main(){
	int i,an[10],sum,t,cnt;
	while(1){
		memset(an,0,sizeof(an));
		sum=0,cnt=0;
		for(i=1;i<=6;i++){
			scanf("%d",&an[i]);
			cnt+=an[i];
		}
		if(cnt==0) break;
		sum+=an[6]+an[5]+an[4]+(an[3]+3)/4;
		if(an[5]){
			if(an[1]>an[5]*11) an[1]-=an[5]*11;
			else an[1]=0;
		}
		if(an[4]){
			t=an[4];
			if(an[2]>an[4]*5) {an[2]-=an[4]*5;cnt=0;}
			else {cnt=an[4]*5*4-an[2]*4;an[2]=0;}
			if(an[1]>cnt) an[1]-=cnt;
			else an[1]=0;
		}
		if(an[3]){
			t=(an[3]+3)/4; 
			cnt=36*t-9*an[3];
			if(cnt==9){
				if(an[2]>1) {t=5;an[2]-=1;}
				else {t=9-an[2]*4;an[2]=0;}
				if(an[1]>t) an[1]-=t;
				else an[1]=0;
			}
			else if(cnt==18){
				if(an[2]>3){t=6;an[2]-=3;}
				else {t=18-an[2]*4;an[2]=0;}
				if(an[1]>t) an[1]-=t;
				else an[1]=0;
			}
			else if(cnt==27){
				if(an[2]>5){t=7;an[2]-=5;}
				else {t=27-an[2]*4;an[2]=0;}
				if(an[1]>t) an[1]-=t;
				else an[1]=0;
			}
		}
		if(an[2]){
			t=(an[2]+8)/9;
			sum+=t;
			if(an[1]>36*t-an[2]*4) an[1]-=36*t-an[2]*4;
			else an[1]=0;
		}
		if(an[1]) sum+=(an[1]+35)/36;
		printf("%d\n",sum);
	}
	return 0;
}

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