Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
帮帮忙 wrong answer#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator