| ||||||||||
| 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 | |||||||||
SOS:请教牛人帮帮忙,或者提供可以使这个程序出错的数据#include<iostream.h>
//--------------------
int result()
{
int a,b,c,d,e,f;
cin>>a>>b>>c>>d>>e>>f;
int sum=0;
sum+=f; f=0; //规格为6×6的产品必须每个占一个箱子
sum+=e; //规格为5×5的产品必须每个占一个箱子
a = a- 11*e; e=0; //5×5的产品占据一个箱子后还可以放11个1×1的产品
if(a<0) a=0; //
sum+=d; //规格为4×4的产品必须每个占一个箱子
b =b- 5*d; d=0; //4×4的产品占据一个箱子后还可以放5个2×2的产品
if (b<0) { //继续在4×4 的箱子里填充1×1的产品
a=a+4*b;
b=0;
if(a<0)
a=0;
}
sum=sum+c/4; c=c%4; //规格为3×3的产品4个占一个箱子
if(c==0)sum=sum+(a+b*4+35)/36;//还剩未知数个2×2、1×1
else if(c==1){ //还剩1个3×3的产品和未知数个2×2、1×1
sum += 1; b-=5; a-=7;
if(b<0){a=a+4*b;b=0;}
if(a<0)a=0;
sum=sum+(a+b*4+35)/36;
}
else if(c==2) { //还剩2个3×3产品和未知数个2×2、1×1
sum += 1; b-=3; a-=6;
if(b<0){a=a+4*b;b=0;}
if(a<0)a=0;
sum=sum+(a+b*4+35)/36;
}
else if(c==3){ //还剩3个3×3产品和未知数个2×2、1×1
sum += 1; b-=1; a-=5;
if(b<0){a=a+4*b;b=0;}
if(a<0)a=0;
sum=sum+(a+b*4+35)/36;
}
return sum;
}
//------------------------
void main()
{
int k[20];
for(int i=0;i<20;i++){
k[i]=result();
if(k[i]==0)break;
}
for (int j=0;j<i;j++)
cout<<k[j]<<endl;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator