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 |
没有思路的可以看看(慎入,有代码)//1017 #include <stdio.h> int ceil(int a, int b)//向上取整 { if (a%b == 0) { return a/b; } else { return a/b+1; } } int main() { int num[7], remain[3], res; while (1) { bool zf = 1; for (int i = 1; i <= 6; ++ i) { scanf("%d",num+i); if (num[i]) { zf = 0; } } if (zf) { break; } res = 0; res += num[6];//6*6 res += num[5];//5*5 remain[1] = (num[5]*11); res += num[4];//4*4 remain[2] = (num[4]*5); res += ceil(num[3],4);//3*3 switch (num[3]%4) { case 0: break; case 1: remain[2] += 5; remain[1] += 7; break; case 2: remain[2] += 3; remain[1] += 6; break; case 3: remain[2] += 1; remain[1] += 5; break; default: break; } if (num[2] <= remain[2]) {//所有2*2的都放进剩余空间里了 remain[2] -= num[2]; num[2] = 0; } else {//还有2*2的没有放进包裹 num[2] -= remain[2]; remain[2] = 0; res += ceil(num[2], 9); if (num[2]%9 != 0) { remain[1] += (9-num[2]%9)*4; } } num[1] -= remain[2]*4+remain[1]; if (num[1]>0) { res += ceil(num[1], 36); } printf("%d\n", res); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator