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 + e + d + ( c + 3 ) / 4; /* 6×6、5×5、4×4,这些规格每个产品 需要一个箱子来装,3×3 规格的产品每4个需要一个箱子*/ c = c % 4; b = b - 5*d - (c ? (7-2*c) : 0);/*把 2×2 规格的产品装在4×4,3×3的箱子的空余处*/ a = a - 11*e - (c ? (8-c) : 0);/*把 1×1 规格的产品装在5×5,3×3的箱子的空余处*/ if ( b < 0) a = a + 4*b;//如果2×2的产品已经放完,就补上1×1的产品 if ( a < 0) a = 0;/*如果1×1的产品也放完,那么资源没有充分利用,但没有别的选择*/ if ( b < 0) b = 0; sum = sum + ( a + 4*b + 35 ) / 36; /*把剩下的2×2、1×1产品放在另外的箱子*/ return sum; //返回数值 } //------------------------ void main () { int k [ 20 ]; for ( int i = 0; i < 20; i ++ ) { k [i] = result (); if ( k [i] == 0 ) break; //如果结果是0,那么只能输入的六个数全是0 } 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