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 |
按非常简单的思路写了很多,不知道哪里错,测试数据discuss里面的都过了#include<stdio.h> #include <memory.h> int p[7]; int main() { while(1) { memset(p,0,sizeof(p)); scanf("%d %d %d %d %d %d",&p[1],&p[2],&p[3],&p[4],&p[5],&p[6]); if(p[1]==0&&p[2]==0&&p[3]==0&&p[4]==0&&p[5]==0&&p[6]==0) break; else { int ans=p[6]; //处理6 // p[6]=0; ans+=p[5]; p[1]=p[1]-p[5]*11>0? p[1]-p[5]*11:0; // p[5]=0;//处理5 ans+=p[4];// if(p[2]<=p[4]*5) //处理4 { int rest =p[4]*5-p[2]; p[2]=0; p[1]=rest*4-p[1]>=0? 0:p[1]-rest*4; } else p[2]=p[2]-p[4]*5; p[4]=0;//... ans+=(p[3]+3)/4;// int mod=p[3]%4; if(mod==1) { if(p[2]>=5) { p[2]-=5; p[1]=p[1]-7>0? p[1]-7:0; } else { p[1]-(27-p[2]*4)>=0?p[1]-(27-p[2]*4):0; p[2]=0; } } else if(mod==2) { if(p[2]>=3) { p[2]-=3; p[1]=p[1]-6>=0?p[1]-6:0; } else { p[1]-(18-p[2]*4)>=0?p[1]-(18-p[2]*4):0; p[2]=0; } } else if(mod==3) { if(p[2]>=1) { p[2]-=1; p[1]=p[1]-5>=0?p[1]-5:0; } else { p[1]-(9-p[2]*4)>=0?p[1]-(9-p[2]*4):0; p[2]=0; } } ans+=(p[2]+8)/9;//printf("ans=%d\n",ans);//处理2 if(p[2]%9==1) { p[1]=p[1]-32>0?p[1]-32:0; } else if(p[2]%9==2) { p[1]=p[1]-28>0?p[1]-28:0; } else if(p[2]%9==3) { p[1]=p[1]-24>0?p[1]-24:0; } else if(p[2]%9==4) { p[1]=p[1]-20>0? p[1]-20:0; } else if(p[2]%9==5) { p[1]=p[1]-16>0?p[1]-16:0; } else if(p[2]%9==6) { p[1]=p[1]-12>0?p[1]-12:0; } else if(p[2]%9==7) { p[1]=p[1]-8>0?p[1]-8:0; } else if(p[2]%9==8) { p[1]=p[1]-4>0?p[1]-4:0; } // printf("ans=%d\n",ans); ans+=(p[1]+35)/36; printf("%d\n",ans); } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator