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

C语言也能行

Posted by bricking at 2009-02-10 09:44:55 on Problem 1664
#include<stdio.h>
int f(int i, int j, int max)
{	int k;
	int sum = 0;
	if( j==1 ) return 1;
	if( i==1 || i==0 ) return 1;
	k=i;
	if(max<i)k=max;
	for( ; k*j>=i; k--)//k值不能小于当前平均每个盘子中的苹果数
	{
		sum = sum + f(i-k, j-1, k);
	}
	return sum;
}
main()
{
	int t, m, n;
scanf("%d",&t);
	while(t--)
	{
		scanf("%d%d",&m,&n);
		printf("%d\n",f(m,n, m+1));
	}
	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