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 tangbohu222 at 2011-03-22 19:56:39 on Problem 1221
#include<stdio.h>
typedef long long ull;
ull ans[401];
ull dp[401][401];
int N=400;

void slove()
{
	for(int i=1;i<=N;i++)
	{
			dp[i][i]=1;//i拆分后最小数字为i的种数为1
	}
	for(int i=1;i<N;i++)
		for(int j=i+1;j<=N;j++)
			dp[i][j]=0;
	for(int i=2;i<=N;i++)

{		for(int j=1;j<=i;j++)
		{
			
			if(i>2*j)
			{
				dp[i][j]+=dp[i-2*j][j];//dp[i][j]等于最小值为j的拆分//dp[i-j][j]代表去掉最外面的两个j之后最小值为j的拆分
				for(int t=1;j+t<=i;t++)
				dp[i][j]+=dp[i-2*j][j+t];//以及去掉最外边的j之后最小值大于j的拆分
			}
			else if((i==2*j)||(i==j))dp[i][j]=1;
			else dp[i][j]=0;
			ans[i]+=dp[i][j];
		}
}
}
int main()
{
	int in;
	slove();
	while(scanf("%d",&in)!=EOF&&in!=0)
	{
		
		printf("%d %lld\n",in,ans[in]);
	}
	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