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

帮帮忙 wrong answer

Posted by IC0590501320 at 2005-12-26 19:36:15 on Problem 1017
#include<stdio.h>
#include<math.h>
int three(int x,int d){  //定义函数 (将4*4的空隙塞满后余的2*2个数;最后一个3*3的箱子里的个数)
	int m;      //需要为2*2多开的箱子数
	switch(d){       //讨论箱子里3*3的个数
	  case 0:m=(x-8)/9; break;    //无空隙,另开箱
      case 1:if(x>5)  m=(x+3)/9; else m=0; break;   //空隙可放5个2*2,多余的另开箱
      case 2:if(x>3)  m=(x+5)/9; else m=0; break;
      case 3:if(x>1)  m=(x+7)/9; else m=0; break;
	}
	return m;        //返回为2*2多开箱的数目
}
void main(){
	int a,b,c,d,e,f;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
	while(a!=0||b!=0||c!=0||d!=0||e!=0||f!=0){     //不全为0时
		int t,n;
		n=f+e+d+(c+3)/4+three(b-d*5,c%4);     //除了1*1的不放所需的箱子
                t=36*f+25*e+16*d+9*c+4*b+1*a-36*n;       //由于1*1可填补所有空隙,只需看木筷总体积与箱子总容积的差,
		if(t<0) t=0;                              以确定是否为1*1另开箱子。
		n=n+(t+35)/36;              //加上为多余的1*1开的箱子
		printf("%d\n",n);                                    //总箱子个数
		scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);         //循环输入
	}
}

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