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

help!!

Posted by linphy at 2004-06-11 18:32:31 on Problem 1032
大家帮我测式下数据,真不知道哪错了。谢了
#include <stdio.h>
#include <malloc.h>
void divide(int *p1,int *p2,int n,int m,int s,unsigned long x,unsigned long &r,int a)
{
        if (n>0)
        {
                p1[m]=s+1;
                divide(p1,p2,n-s-1,m+1,s+1,x*(s+1),r,0);
                if (a==0)
				{
                       p1[m]=s+2;
					   divide(p1,p2,n-s-2,m+1,s+2,x*(s+2),r,1);
                }
        }
        else if (n==0) 
        {
                if (x>r) 
                {
                        r=x;
                        for (int j=0;j<m;j++) p2[j]=p1[j];
                        p2[j]=0;
                }
        }
}
void main()
{
        int n,i;unsigned long r=0;
        scanf("%d",&n);
        int *p1=(int *)(malloc(sizeof(int)*(n+1)));
        int *p2=(int *)(malloc(sizeof(int)*(n+1)));
        for (i=1;i<=3;i++) divide(p1,p2,n,0,i,1,r,0);
        for (n=0;p2[n]!=0;n++) printf("%d ",p2[n]);
}

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