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

Re:Hellp! My code here ! plz give me some test data,i'm always wa, thx a lot!

Posted by ACM06019 at 2006-10-13 12:00:44 on Problem 3014
In Reply To:Re:Hellp! My code here ! plz give me some test data,i'm always wa, thx a lot! Posted by:ACM06019 at 2006-10-13 12:00:10
Sorry code here!


#include <stdio.h>

#define maxn 4501

#define MOD 1000000007

int dp[maxn][maxn];

int main()
{
	int n,m,i,j;
	scanf("%d%d",&m,&n);
	for (i=0; i<=m; i++) dp[1][i]=dp[0][i]=1;
	for (i=0; i<=n; i++) dp[i][1]=dp[i][0]=1;
	for (i=2; i<=n; i++)
		for (j=2; j<=i && j<=m;  j++)
			{
				if (i-j<=j) dp[i][j] = (dp[i][j-1]+dp[i-j][i-j])%MOD;
				else
				dp[i][j]=(dp[i][j-1]+dp[i-j][j]) % MOD;
			}
	if (m<=n) 
	printf("%d",dp[n][m]);
	else printf("%d",dp[n][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