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

我的代码,动态规划

Posted by 2007011268 at 2009-02-26 13:29:26 on Problem 1664
# include <iostream>
using namespace std;
int main()
{
	int b[11][11];
	int t,m,n;
	cin>>t;
	for(int i=0;i<t;i++)
	{
		cin>>m>>n;
		for(int j=1;j<=n;j++)
			b[1][j]=1;
		for(int i=2;i<=m;i++)
			b[i][1]=1;
		for(int i=0;i<=n;i++)
			b[0][i]=1;
		for(int i=2;i<=m;i++)
			for(int j=2;j<=n;j++)
			{
				b[i][j]=0;
				for(int k=0;k<=i/j;k++)
				{
					b[i][j]=b[i][j]+b[i-k*j][j-1];
				}
			}
		cout<<b[m][n]<<endl;
	}
	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