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 |
我受不了了~试了无数组数据,到地错在哪里啊!!!!#include <iostream.h> #include <math.h> void main() { int packet[7]={0,0,0,0,0,0,0}; int n=0,parcel; for(int i=1;i<7;i++) { cin>>packet[i]; if(packet[i]==0) n++; } while(n!=6) { n=0; parcel=0; parcel=packet[3]/4+packet[4]+packet[5]+packet[6]; if(packet[1]>11*packet[5]) { packet[1]=packet[1]-11*packet[5]; } else { if(packet[5]!=0) packet[1]=0; } int p=0; if(packet[2]>packet[4]*5) { packet[2]=packet[2]-5*packet[4]; } else { if(packet[4]!=0) { packet[2]=0; p=packet[4]*5-packet[2]; if(packet[1]>4*p) packet[1]=packet[1]-4*p; else packet[1]=0; } } packet[3]=packet[3]%4; if(packet[3]==0) { parcel=parcel+packet[2]/9; packet[2]=packet[2]%9; if(packet[2]==0) { if(packet[1]==0) { cout<<parcel<<endl; } else { cout<<parcel+(int)ceil((double)packet[1]/36)<<endl; } } else { parcel++; packet[1]=packet[1]-(9-packet[2])*4; if(packet[1]>0) cout<<parcel+(int)ceil((double)packet[1]/36)<<endl; else cout<<parcel<<endl; } } else { parcel++; if(packet[3]==3) { packet[2]=packet[2]-1; packet[1]=packet[1]-5; } else { if(packet[3]==2) { packet[1]=packet[1]-6; packet[2]=packet[2]-3; } else { packet[1]=packet[1]-7; packet[2]=packet[2]-5; } } if(packet[2]<=0) { packet[1]=packet[1]+packet[2]*4; packet[2]=0; } if(packet[1]<=0) packet[1]=0; parcel=parcel+packet[2]/9; packet[2]=packet[2]%9; if(packet[2]==0) { if(packet[1]==0) { cout<<parcel<<endl; } else { cout<<parcel+(int)ceil((double)packet[1]/36)<<endl; } } else { parcel++; packet[1]=packet[1]-(9-packet[2])*4; if(packet[1]>0) cout<<parcel+(int)ceil((double)packet[1]/36)<<endl; else cout<<parcel<<endl; } } for(i=1;i<7;i++) { cin>>packet[i]; if(packet[i]==0) n++; } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator