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。之前测试了别人提供的所有测试用例都没有错。希望能对大家有所帮助。 我试了,是23~可是到底哪错了呢? #include<stdio.h> #define N 7 int main() { int i,num[N],cnt=0; while(1) { for(i = 1;i < N;i++) scanf("%d",&num[i]); cnt=0; if(num[1]+num[2]+num[3]+num[4]+num[5]+num[6]==0) break; cnt+=num[6]; cnt+=num[5]; num[1]-=num[5]*11; if(num[1]<0) num[1]=0; cnt+=num[4]; if(num[2]>=num[4]*5) num[2]-=num[4]*5; else { num[1]-=20*num[4]-num[2]*4; num[2]=0; } if(num[1]<0) num[1]=0; if(num[2]<0) num[2]=0; cnt+=(num[3]+3)/4; if(num[3]%4==1) { if(num[2]>=5) { num[2]-=5; num[1]-=7; } else { num[1]-=27-4*num[2]; num[2]=0; } } if(num[3]%4==2) { if(num[2]>=3) { num[2]-=3; num[1]-=6; } else { num[1]-=18-num[2]*4; num[2]=0; } } if(num[3]%4==3) { if(num[2]>=1) { num[2]-=1; num[1]-=5; } else num[1]-=9; } if(num[2]>0) { cnt+=(num[2]+8)/9; num[1]-=36-(num[2]/9)*4; if(num[1]<0) num[1]=0; } cnt+=(num[1]+35)/36; printf("%d\n",cnt); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator