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 |
Re:可以试试58 63 33 3 3 3 结果为24In Reply To:可以试试58 63 33 3 3 3 结果为24 Posted by:wxdlut at 2008-11-06 23:34:56 > 我就因为没考虑装满3*3箱子还余下的3*3箱子不为零时,计数没有加1。之前测试了别人提供的所有测试用例都没有错。希望能对大家有所帮助。 我的是24啊,但还是错了 #include <stdio.h> #include <string.h> int main() { int pro[6] = {0}; int count = 0; while(1) { scanf("%d%d%d%d%d%d", &pro[0], &pro[1], &pro[2], &pro[3], &pro[4], &pro[5]); if(pro[0]+pro[1]+pro[2]+pro[3]+pro[4]+pro[5] == 0) break; else { int t = 0; int box[6][6] = {0}; count = pro[5]+pro[4]+pro[3]+(pro[2]+3)/4; t = 20*pro[3] - 4*pro[1]; pro[1] = t >= 0 ? 0 : pro[1] - 5*pro[3]; pro[0] = pro[0] <= 11 * pro[4] ? 0 : pro[0] - 11*pro[4]; if(t > 0) pro[0] = pro[0] <= t ? 0 : pro[0] - t; pro[2] = pro[2]%4; switch(pro[2]) { case 0: count += (4*pro[1]+pro[1]+35) / 36; break; case 1: if(pro[1] > 5) { pro[1] -= 5; pro[0] = pro[0] <= 7 ? 0 : pro[0]-7; count += (4*pro[1]+pro[0]+35) / 36; } else{ if(pro[0] > 27 - 4*pro[1]){ pro[0] = pro[0] - (27 - 4*pro[1]); count += (pro[0]+35) / 36; } } break; case 2: if(pro[1] > 3){ pro[1] -= 3; pro[0] = pro[0] <= 6 ? 0 : pro[0] - 6; count += (4*pro[1]+pro[0]+35) / 36; } else { if(pro[0] > 18 - 4*pro[1]){ pro[0] = pro[0] - (18 - 4*pro[1]); count += (pro[0]+35) / 36; } } break; case 3: if(pro[1] > 1) { pro[1] -= 1; pro[0] = pro[0] <= 5 ? 0 : pro[0] - 5; count += (4*pro[1]+pro[0]+35) / 36; } else { if(pro[0] > 9 - 4*pro[1]){ pro[0] = pro[0] - (9 - 4*pro[1]); count += (pro[0]+35) / 36; } } break; default : break; } printf("%d\n", count); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator