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

只要将HDOJ1028的代码稍微改下就好~水~【附代码】

Posted by xiexinxinlove at 2014-08-08 21:33:28 on Problem 1664
/*
POJ 1664
@author: NGUper
这个放苹果的问题其实和HDU 1028很相似 
*/
#include <iostream>
#include <cstdio>
using namespace std;
const int Max = 10 + 5;
int main()
{
	int n;
	int f[Max][Max];
	
	//先进行预处理
	f[0][0] = f[1][1] = 1;
	for(int i=2; i<=Max-1; i++)
	{
		f[i][1] = 1;
		for(int j=2; j<=i; j++)
		{
			int k;
			if(i-j < j) //注意考虑m>n的情况!
			{
				k = i-j;
			}
			else
			{
				k = j;
			}	 
			f[i][j] = f[i-j][k] + f[i][j-1];
		}
	}
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n,m;
		scanf("%d %d",&n,&m);
		cout<<f[n][m]<<endl;
	}
}
		
	
	
		
			
			
 

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