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 kanesunny at 2017-11-18 23:21:46 on Problem 1664 and last updated at 2017-11-18 23:39:19
#include<stdio.h>

int dps(int m, int n,int pre) {
	int i,sum=0;
	if (n == 1) {
		return 1;
	}
	for (i = pre; i<= m/n; i++) { //下一层的苹果都大于等于上一层的苹果
		sum+=dps(m - i, n - 1,i);
	}
	return sum;
}

int main() {
	int m, n, t, i;
	scanf("%d", &t);
	for (i = 0; i < t; i++) {
		scanf("%d%d", &m, &n);
		 printf("%d\n", dps(m, n, 0));
	}
	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