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

判重其实很好办..不用Hash..不用Map..只要一条语句..

Posted by zzyzzy12 at 2010-12-29 18:24:05 on Problem 1564 and last updated at 2010-12-29 18:24:39
核心代码:
void find(int p,int m)
{
  int i;   
  if (m>k) return;
  if (m==k) 
  { 
     f=false;  
     printf("%d",h[1]);
     for (i=2;i<=x;i++) printf("+%d",h[i]);   
     printf("\n");  
     return;
  }   
  for (i=p+1;i<=n;i++)
  {
   x++;
   h[x]=a[i];
   find(i,m+a[i]);
   x--;
   while  ((i<=n)&&(a[i]==a[i+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