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

Re:贴代码 跟测试数据~测试数据来自其他人

Posted by gnolizuh at 2012-10-26 15:15:15 on Problem 1017
In Reply To:贴代码 跟测试数据~测试数据来自其他人 Posted by:crazypapa at 2012-09-06 15:48:42
> #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