Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
多叉树的方法#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator