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> using namespace std; bool ans[500];int i=0; int M[6]; bool search(int len,int rest) { if(len<1) return false; if(rest%len==0&&rest/len<=M[len-1]) return true; else { rest-=len*min(rest/len,M[len-1]); if(search(len-1,rest)) return true; else for(int j=1;j<min(rest/len,M[len-1]);++j) if(search(len,rest+j*len)) return true; } return false; } bool judge() { int all=M[0]+2*M[1]+3*M[2]+4*M[3]+5*M[4]+6*M[5]; if(all%2) return false; else return search(6,all/2); } int main() { cin>>M[0]>>M[1]>>M[2]>>M[3]>>M[4]>>M[5]; while(M[0]|M[1]|M[2]|M[3]|M[4]|M[5]) { ans[i++]=judge(); cin>>M[0]>>M[1]>>M[2]>>M[3]>>M[4]>>M[5]; } for(int j=0;j<i;++j) { printf("Collection #%d:\n",j+1); printf(ans[j]?"Can be divided.":"Can't be divided."); cout<<endl<<endl; } system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator