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!!, 我是用NP做的,提交总是报RE#include <iostream> #include <memory> #include <vector> using namespace std; struct node { short num[6]; }; int main() { short sum, count=0, i, j; short *find; node my; vector<node> left; while(true) { count++; for(sum=0,i=0;i<6;i++) { cin>>my.num[i]; sum+=my.num[i]*(i+1); } if(sum==0) break; else if(sum%2==1) cout<<"Collection #"<<count <<":\nCan't be divided.\n\n"; else { sum/=2; find=new short[sum+1]; memset(find,-1,(sum+1)*sizeof(short)); find[0]=0; left.push_back(my); for(i=1;i<=sum;i++) { for(j=1;j<=6;j++) { if(i>=j&&find[i-j]!=-1) { if(left.at(find[i-j]).num[j-1]>0) { my=left.at(find[i-j]); my.num[j-1]=my.num[j-1]-1; find[i]=left.size(); left.push_back(my); } } } } if(find[sum]!=-1) cout<<"Collection #"<<count <<":\nCan be divided.\n\n"; else cout<<"Collection #"<<count <<":\nCan't be divided.\n\n"; delete[] find; left.clear(); } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator