| ||||||||||
| 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 | |||||||||
判重其实很好办..不用Hash..不用Map..只要一条语句..核心代码:
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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator