Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

tips

Posted by lqp18_31 at 2009-08-03 08:42:17 on Problem 1980
void dfs( int step , int last , int now , bignum rest  )
{
     if( rest.p==0 ){
       //  for( int i=0 ; i<step ; i++)  fprintf( fout ,"%d ",ans[ i ]);
         sum++;//  cout << endl;
         return ;
     }
     if( step>=n )return;
     int Min=rest.q/rest.p+(rest.q%rest.p!=0),Max=a/now;
     if( Min < last ) Min = last;
     for( int i=Min ; i <= Max ; i++){
          bignum t( n-step , i );   // 这句应该写在这里,而不是下次递归才判断,否则TLE
          if( t<rest ) return;     // 这个return ,饿……
          dfs( step+1 , i , now*i , rest-bignum( 1 , i ) );
     }
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator