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 |
无语了,测试数据也都过了,为什么还WA呢?真理难寻呀#include<iostream> #include<cstring> #include<stdio.h> using namespace std; int co[9],num; bool flag[120010],cnt[120010]; void package(int i) { int p,q; if(co[i]==1) { for(p=num;p>=i;p--) if(!flag[p]&&flag[p-i])flag[p]=true; } else if(co[i]!=1&&i*co[i]>=num) { for(p=i;p<=num;p++) if(flag[p-i]&&(!flag[p])) flag[p]=true; } else if(co[i]!=1&&i*co[i]<num) { memset(cnt,0,sizeof(cnt)); for(p=i;p<=num;p++) { if(!flag[p]&&flag[p-i]&&cnt[p-i]<co[i]) { flag[p]=true; cnt[p]=cnt[p-i]+1; } } } } int main() { int i,j,ti=1; while(scanf("%d%d%d%d%d%d",&co[1],&co[2],&co[3],&co[4],&co[5],&co[6])==6) { if(!(co[1]+co[2]+co[3]+co[4]+co[5]+co[6]))break; num=co[1]+2*co[2]+3*co[3]+4*co[4]+5*co[5]+6*co[6]; if(num%2!=0) { cout<<"Collection #"<<ti++<<':'<<endl; cout<<"Can't be divided."<<endl<<endl; } else { num=num/2; memset(flag,false,sizeof(flag)); flag[0]=true; for(i=1;i<=6;i++) if(co[i]!=0) package(i); if(flag[num]) { cout<<"Collection #"<<ti++<<':'<<endl; cout<<"Can be divided."<<endl<<endl; } else { cout<<"Collection #"<<ti++<<':'<<endl; cout<<"Can't be divided."<<endl<<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