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:动态规划问题,这题数据太弱,应该加强,贴上代码

Posted by gdin2014cs05 at 2015-09-07 22:44:54 on Problem 1664
In Reply To:动态规划问题,这题数据太弱,应该加强,贴上代码 Posted by:ld2rxt at 2014-09-16 22:06:20
> #include<stdio.h>
> int dp[12][12];
> int justdo(int m, int n)
> {
> 	if(m<0)
> 		return 0;
> 
> 	if(n==1 || m==0)
> 		return dp[m][n] = 1;
> 
> 	if(dp[m][n])
> 		return dp[m][n];
> 	else
> 	{
> 		int num = 0, k = 1;
> 	    for(;;k++)
> 		{
> 			num+=justdo(m-k*n,n-1);
> 			if(m-k*n<=0)
> 				break;
> 		}
> 	    return dp[m][n] = justdo(m,n-1) + num;
> 	}
> }
> int main()
> {
> 	int t,m,n;
> 	scanf("%d",&t);
> 	while(t--)
> 	{
> 		scanf("%d %d",&m,&n);
> 		printf("%d\n",justdo(m,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