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

跪求大牛们帮我看看,1000个数据测完结果不是多一个1就是少一个1,哪里错了

Posted by lymyfz at 2011-03-23 20:17:29 on Problem 1017
#include<iostream>
using namespace std;
int main()
{
	int a[7],i,t;
	while(cin>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6],a[1]||a[2]||a[3]||a[4]||a[5]||a[6])
	{
		
		int cou=0;
		t=0;	
		cou+=a[6];
		cou+=a[5];
		a[1]=a[1]-a[5]*11;
		cou+=a[4];
		a[2]=a[2]-a[4]*5;
		if(a[2]<0)
		a[1]=a[1]+a[2]*4;
//		cout<<cou<<endl;
		if(a[3]!=0 && a[3]%4!=0)
		cou+=a[3]/4+1;
		else
		cou+=a[3]/4;
		t=a[3]%4;
		if(t==1)
		{
			a[2]=a[2]-5;
			if(a[2]<0)
			a[1]+=(a[2]*4-7);
			else
			a[1]=a[1]-7;
		}
//		cout<<cou<<endl;
		if(t==2)
		{
			a[2]-=3;
			if(a[2]<0)
			a[1]+=(a[2]*4-6);
			else
			a[1]-=6;
		}
		if(t==3)
		{
			a[2]-=1;
			if(a[2]<0)
			a[1]+=(a[2]*4-5);
			else
			a[1]-=5;
		}
//		cout<<cou<<endl;
		if(a[2]>0)
		{//system("pause");
		     if(a[2]%9!=0)
			cou+=a[2]/9+1;
			else
			cou+=a[2]/9;
	     	t=9-a[2]%9;
     		a[1]-=(36-t*4);
		}
		if(a[1]>0)
		{
			if(a[1]%36!=0)
			cou+=a[1]/36+1;
			else
			cou+=a[1]/36;
		}
//		memset(a,0,sizeof(a));
		cout<<cou<<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