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

我交了5次了,很多数据测试都过了,可一直都wrong answer,为什么?下面是我的程序,请高手改改。

Posted by E10614013 at 2008-07-12 10:26:32 on Problem 1017
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
	int a[7]={0};
	int i;
	for(i=1;i<7;i++)
		cin>>a[i];
	while(a[1]||a[2]||a[3]||a[4]||a[5]||a[6])
	{
		a[0]=0;
		if(a[6])
			a[0]=a[6];
		if(a[5])
		{
			a[0]+=a[5];
			if(a[1])
				a[1]=a[1]-11*a[5];
			if(a[1]<0)
				a[1]=0;
		}
		if(a[4])
		{
			a[0]+=a[4];
			if(a[2])
				a[2]=a[2]-5*a[4];
			if(a[2]<0)
			{
				if(a[1])
				a[1]=a[1]+a[2]*4;
				if(a[1]<0)
					a[1]=0;
				a[2]=0;
			}
		}
		if(a[3])
		{
			a[0]+=ceil(a[3]/4.0);
			switch(a[3]%4)
			{
			case 1:
				if(a[2])
				{
					a[2]=a[2]-5;
					if(a[1])
					{
						if(a[2]>=0)
							a[1]=a[1]-7;
						else
							a[1]=a[1]+a[2]*4-7;
					}
				}
				if(a[2]<0)
					a[2]=0;
				if(a[1])
					a[1]=a[1]-27;
				if(a[1]<0)
					a[1]=0;
				break;
			case 2:
				if(a[2])
				{
					a[2]=a[2]-3;
					if(a[1])
					{
						if(a[2]>=0)
							a[1]=a[1]-6;
						else
							a[1]=a[1]+a[2]*4-6;
					}
				}
				if(a[2]<0)
					a[2]=0;
				if(a[1])
					a[1]=a[1]-18;
				if(a[1]<0)
					a[1]=0;
				break;
			case 3:
				if(a[2])
				{
					a[2]=a[2]-1;
					if(a[1])
					{
						if(a[2]>=0)
							a[1]=a[1]-1;
						else
							a[1]=a[1]+a[2]*4-1;
					}
				}
				if(a[2]<0)
					a[2]=0;
				if(a[1])
					a[1]=a[1]-9;
				if(a[1]<0)
					a[1]=0;
				break;
			default:
				break;
			}
		}
		if(a[2])
		{
			a[0]+=ceil(a[2]/9.0);
			if(a[2]%9)
			{
				if(a[1])
					a[1]=a[1]-(36-a[2]%9*4);
				if(a[1]<0)
					a[1]=0;
			}
		}
		if(a[1])
		{
			a[0]+=ceil(a[1]/36.0);
		}
		cout<<a[0]<<endl;
		for(i=1;i<7;i++)
			cin>>a[i];
	}
	
	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