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

WA了一晚上了 谁知道特殊点的数据啊 极大/极小/一般的数据都试过了都是对的

Posted by entrails at 2007-01-05 20:42:14 on Problem 1095
#include <stdio.h>
#include <memory.h>
#define MaxNN 19
unsigned long ep[MaxNN],sn[MaxNN];
unsigned long rep[MaxNN][MaxNN],rsn[MaxNN][MaxNN];
int i,j;
unsigned long n;
int tree(unsigned long x)
{
	int ix,jx;
	unsigned long xl,xr;
	ix=1;
	while (ep[ix]<x) ix++;
	jx=0;
	while (rep[jx][ix-1-jx]<x-ep[ix-1]) jx++;
	if (jx) xl=(x-ep[ix-1]-rep[jx-1][ix-jx]-1)/sn[ix-1-jx]+1+ep[jx-1];
	else xl=0;
	if (ix-1-jx) xr=(x-ep[ix-1]-rep[jx-1][ix-jx]-1)%sn[ix-1-jx]+1+ep[ix-jx-2];
	else xr=0;
	if (xl!=0)
	{
		printf("(");
		tree(xl);
		printf(")");
	}
	printf("X");
	if (xr!=0)
	{
		printf("(");
		tree(xr);
		printf(")");
	}
	return 0;
}
int main()
{
	memset(sn,0,sizeof(sn));
	memset(ep,0,sizeof(ep));
	memset(rep,0,sizeof(rep));
	memset(rsn,0,sizeof(rsn));
	sn[0]=1;
	ep[0]=0;
	for (i=1;i<=MaxNN-1;i++)
	{
		for (j=0;j<=i-1;j++) 
		{
			rsn[j][i-1-j]=sn[j]*sn[i-1-j];
			sn[i]=sn[i]+rsn[j][i-1-j];
			if (j==0) rep[j][i-1-j]=rsn[j][i-1-j];
			else rep[j][i-1-j]=rep[j-1][i-j]+rsn[j][i-1-j];
		}
		ep[i]=ep[i-1]+sn[i];
	}
	for (i=0;i<=MaxNN-1;i++) printf("%ld\n",ep[i]);
	scanf("%ld",&n);
	while (n)
	{
		tree(n);
		printf("\n");
		scanf("%ld",&n);
	}
	
	return 0;
}

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