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 |
过了 谢谢数据In Reply To:终于AC了,WA的我好惨啊,真的要小心,提供1000组测试数据,如果都过了,基本差不多了 Posted by:Ontheline at 2009-01-09 10:51:23 贴下奇丑无比的代码 #include<iostream> #include<fstream> using namespace std; int num[7]; int main() { //ifstream cin("data.txt"); //ofstream cout("out.txt"); //40 942 264 8 6 5 for(;;) { int i; for(i=1; i<=6; i++) cin>>num[i]; if(num[1]==0&&num[2]==0&&num[3]==0&&num[4]==0&&num[5]==0&&num[6]==0) break; int ans=num[6];//6 ans+=num[5];//5 if(num[1]>=num[5]*11) num[1]-=num[5]*11; else num[1]=0; if(num[4]) { ans+=num[4];//4 if(num[2]>=num[4]*5)num[2]-=num[4]*5; else { int temp=4*(num[4]*5-num[2]); //剩下的装1 num[2]=0; if(num[1]>=temp) num[1]-=temp; else num[1]=0; } } //3 if(num[3]) { ans+=(num[3]+3)/4; int box3=4-num[3]%4; //剩下的3*3的个数 if(box3==4)box3=0; if(box3==2) { int t; if(num[2]>3){ num[2]-=3; t=3;} else { t=num[2]; num[2]=0;} if(num[1]>=box3*9-t*4)num[1]-=( box3*9-t*4) ; else num[1]=0; } else if(box3!=0) { if(box3==1) { if(num[2]==0) { if(num[1]>=9)num[1]-=9; else num[1]=0; } else { num[2]-=1; if(num[1]>=5)num[1]-=5; else num[1]=0; } } else //box3==3 { int tt; if(num[2]>=5){ num[2]-=5; tt=5;} else { tt=num[2]; num[2]=0; } if(num[1]>=box3*9-tt*4)num[1]-=(box3*9-tt*4); else num[1]=0; } } } //2 if(num[2]) { ans+=(num[2]+8)/9; int box2=9-num[2]%9; if(box2==9)box2=0; if(num[1]>=box2*4)num[1]-=box2*4; else num[1]=0; } //1 if(num[1]) { ans+=(num[1]+35)/36; } cout<<ans<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator