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 |
此代码 30 30 30 30 30 30的数据都没有输出.居然能AC...In Reply To:这题我过得糊糊涂涂, 加了个30就AC , 哪位给讲讲 Posted by:anonym11 at 2004-11-04 15:14:48 > #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