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 crazypapa at 2012-09-06 15:48:42 on Problem 1017
> Input:
> 0 0 4 0 0 1
> 7 5 1 0 0 0
> 36 9 4 1 1 1
> 0 9 4 1 1 0
> 0 0 4 0 0 0
> 36 0 0 0 0 0
> 0 9 0 0 0 0
> 79 96 94 30 18 14
> 53 17 12 98 76 54
> 83 44 47 42 80 3
> 15 26 13 29 42 40
> 41 61 36 90 54 66
> 78 56 445 45 23 65
> 13 4 8 29 45 3
> 15 75 45 98 34 53
> 40 9 0 2 0 0
> 41 9 0 2 0 0
> 44 0 0 0 4 0
> 0 2 3 0 0 0
> 37 7 2 0 1 0
> 12 2 0 1 0 0
> 13 2 0 1 0 0
> 0 0 0 0 0 0
> 
> Output:
> 2
> 1
> 6
> 4
> 1
> 1
> 1
> 86
> 231
> 137
> 115
> 219
> 245
> 79
> 197
> 3
> 4
> 4
> 2
> 3
> 1
> 2
#include<stdio.h>

//#define DEBUG

int main()
{
	int num[6]={0};
	int packets=0;
	int n1=0;
	int flag=0;//作为输入0的数目 程序结束标志
	int left_2=0;//二号规格的箱子剩余的空位
	int left_1=0;//一号箱子所剩下的空位

	while(1)
	{
		for(n1=0;n1<6;n1++)
		{
			scanf("%d",num+n1);
			if(*(num+n1)==0)
			{
				flag++;
			}
		}
		if(flag==6) break;
		else flag=0;
		
		packets=num[5]+num[4]+num[3];
		left_2=num[3]*5;
		left_1=num[4]*11;
#ifdef DEBUG
		printf("packets  %d\n",packets);
		printf("left_1  %d\n",left_1);
		printf("left_2  %d\n",left_2);
		printf("**************\n");
#endif
		if(num[2]%4) 
		{
			packets+=num[2]/4+1;
			left_2+=((3-num[2]%4)*2)+1;
			left_1+=8-num[2]%4;
#ifdef DEBUG
			printf("packets  %d\n",packets);
			printf("left_1  %d\n",left_1);
			printf("left_2  %d\n",left_2);
			printf("**************\n");
#endif 
		}

		else  packets+=num[2]/4;
		if(num[1]>left_2)
		{
			if((num[1]-left_2)%9)
			{
				packets+=(num[1]-left_2)/9+1;			
				left_1+=(36-((num[1]-left_2)%9)*4);
			}
			else packets+=(num[1]-left_2)/9;
#ifdef DEBUG
			printf("packets  %d\n",packets);
			printf("left_1  %d\n",left_1);
			printf("left_2  %d\n",left_2);
			printf("**************\n");
#endif
		}
		else 
		{
			left_1+=(left_2-num[1])*4;
#ifdef DEBUG
			printf("packets  %d\n",packets);
			printf("left_1  %d\n",left_1);
			printf("left_2  %d\n",left_2);
			printf("**************\n");
#endif
		}
		if(num[0]>left_1)
		{
			if((num[0]-left_1)%36)
			{
				packets+=(num[0]-left_1)/36+1;
			}
			else packets+=(num[0]-left_1)/36;
		}

		printf("%d\n",packets);	
		packets=0;//在对一次数据处理完成之后 对所用到的数据初始化 但是假如把处
			      //理过程放在函数那么 就用不着了 只需要返回最后那个output就行~
		left_1=0;
		left_2=0;
	}
	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