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"stdio.h" int a[6]; inline int min(int x,int y) { return x<y?x:y; } bool f(int j, int b) { if( j ==-1 ) return false; int k=a[j], p=b; while(k!=0) { p-=j+1; if(p==0) return true; k--; } p=j+1; for( k=p * min(a[j], b/p); k>=0; k-=p) if( f(j - 1, b - k ) ) return true; return false; } int main() { int t; int i1 = 0; while(++i1) { t = 0; scanf("%d%d%d%d%d%d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5]); t = a[0]*1+a[1]*2+a[2]*3+a[3]*4+a[4]*5+a[5]*6; if( t == 0 ) break; if( t & 1) { printf("Collection #%d:\nCan't be divided.\n\n",i1); continue; } if( f( 5 , t/2 ) ) printf("Collection #%d:\nCan be divided. \n\n",i1); else printf("Collection #%d:\nCan't be divided.\n\n",i1); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator