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 |
31 0 1 2 0 0In Reply To:这题我过得糊糊涂涂, 加了个30就AC , 哪位给讲讲 Posted by:anonym11 at 2004-11-04 15:14:48 这组数据明显可分,但如果按你的程序,结果应该是不可分。 所以我认为是测试数据覆盖面不够造成的 AC ,也就是说这段程序仍然有问题。 > #include<stdio.h> > > int ok ; > int d[6] ; > > void find ( int now , int x ) > { > if ( x < 0 ) > return ; > > int s , i ,t = now / (x+1) ; > s = t > d[x] ? d[x] : t ; > if ( now - s * (x+1) != 0 ) > for ( i = s ; i >= 0 ; i -- ) > { > find ( now - i * (x+1) , x-1 ) ; > if ( ok ) > return ; > } > else > { > ok = 1 ; > return ; > } > return ; > } > > int main () > { > int i ,sum ,t = 0 ; > while ( 1 ) > { > for ( i = 0,sum = 0 ; i < 6 ;i ++ ) > { > scanf ( "%d",&d[i] ) ; > d[i] %= 30 ; // 用30除一下,就这样过了,不十分明白,当时只是想用它转化 > sum += d[i] * ( i+1 ) ; > } > if ( sum == 0 ) > break ; > ok = 0 ; > if ( sum % 2 ) > printf ( "Collection #%d:\nCan't be divided.\n\n",++t ) ; > else > { > find ( sum/2 , 5 ) ; > if ( ok ) > printf ( "Collection #%d:\nCan be divided.\n\n",++t ) ; > else > printf ( "Collection #%d:\nCan't be divided.\n\n",++t ) ; > } > } > return 0 ; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator