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 allenlin at 2005-03-23 09:41:26 on Problem 1017
#include <iostream.h>
#include <math.h>


void main()
{	
	int packet[7]={0,0,0,0,0,0,0};
	int n=0,parcel;
	for(int i=1;i<7;i++)
	{
		cin>>packet[i];
		if(packet[i]==0)
			n++;
	}
	while(n!=6)
	{	
		n=0;
		parcel=0;
		parcel=packet[3]/4+packet[4]+packet[5]+packet[6];
		if(packet[1]>11*packet[5])
		{
			packet[1]=packet[1]-11*packet[5];
		}
		else
		{
			if(packet[5]!=0)
				packet[1]=0;
		}
		int p=0;
		if(packet[2]>packet[4]*5)
		{
			packet[2]=packet[2]-5*packet[4];
		}
		else
		{
			if(packet[4]!=0)
			{
				packet[2]=0;
				p=packet[4]*5-packet[2];
				if(packet[1]>4*p)
					packet[1]=packet[1]-4*p;
				else
					packet[1]=0;
			}
		}
		packet[3]=packet[3]%4;
		if(packet[3]==0)
		{
			parcel=parcel+packet[2]/9;
			packet[2]=packet[2]%9;
			if(packet[2]==0)
			{
				if(packet[1]==0)
				{
					cout<<parcel<<endl;
				}
				else
				{
					cout<<parcel+(int)ceil((double)packet[1]/36)<<endl;
				}
			}
			else
			{
				parcel++;
				packet[1]=packet[1]-(9-packet[2])*4;
				if(packet[1]>0)
					cout<<parcel+(int)ceil((double)packet[1]/36)<<endl;
				else
					cout<<parcel<<endl;
			}
		}	
		else
		{
			parcel++;
			if(packet[3]==3)
			{
				packet[2]=packet[2]-1;
				packet[1]=packet[1]-5;
			}
			else
			{
				if(packet[3]==2)
				{
					packet[1]=packet[1]-6;
					packet[2]=packet[2]-3;
				}
				else
				{	packet[1]=packet[1]-7;
					packet[2]=packet[2]-5;
				}
			}
				if(packet[2]<=0)
				{
					packet[1]=packet[1]+packet[2]*4;
					packet[2]=0;
				}
				if(packet[1]<=0)
					packet[1]=0;
			
				parcel=parcel+packet[2]/9;
				packet[2]=packet[2]%9;
				if(packet[2]==0)
				{
					if(packet[1]==0)
					{
						cout<<parcel<<endl;
					}
					else
					{
						cout<<parcel+(int)ceil((double)packet[1]/36)<<endl;
					}
				}
				else
				{
					parcel++;
					packet[1]=packet[1]-(9-packet[2])*4;
					if(packet[1]>0)
						cout<<parcel+(int)ceil((double)packet[1]/36)<<endl;
					else
						cout<<parcel<<endl;
				}
		}
		for(i=1;i<7;i++)
		{
			cin>>packet[i];
			if(packet[i]==0)
			n++;
		}
	}
}





		




	

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