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 blablabla at 2006-02-28 18:53:28 on Problem 1017
In Reply To:终于过了,这道题适合给女孩做,太多细节了;BTW,不是哪个课程的作业吧? Posted by:blablabla at 2006-02-28 18:50:26
#include<iostream>
using namespace std;


int upperInt(int integer,int mod)
{
	if(integer%mod==0)
		return integer/mod;
	else
		return integer/mod+1;
}

int main()
{
	
	while(true)
	{
		int sum;
		int parcel;
		int b[7];
		int i;
		sum=0;
		for(i=1;i<=6;i++)
		{
			cin>>b[i];
			sum+=i*i*b[i];
		}
		if(sum==0)
			break;
		parcel=b[6]+b[5]+b[4]+upperInt(b[3],4);
		int room22=5*b[4]; //extra room for 2*2
		int room11=11*b[5];//extra room for 3*3
		switch(b[3]%4)
		{
		case 1: room22+=5;room11+=7;break;
		case 2: room22+=3;room11+=6;break;
		case 3: room22+=1;room11+=5;break;
		}
		if(b[2]<=room22)
		{
			room11+=(room22-b[2])*4;
			
			if(b[1]>room11)
			{
				parcel+=upperInt(b[1]-room11,36);
			}
		}
		else
		{
			int more22=b[2]-room22;
			parcel+=upperInt(more22,9);
			if(more22%9!=0)
				room11+=(9-(more22%9))*4;
			if(b[1]>room11)
			{
				parcel+=upperInt(b[1]-room11,36);
			}
		}
		cout<<parcel<<endl;

	}
		
		
	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