http://acm.pku.edu.cn/JudgeOnline/problem?id=1664 还是没理解为什么这么做 #include<stdio.h> int dg(int m, int n) { if(m < 0) return 0; if(m == 0 || n == 1) return 1; return dg(m-n, n) + dg(m, n-1); } int main() { int t, m, n; while(scanf("%d", &t) != EOF) { while(t--) { scanf("%d%d", &m, &n); printf("%d/n", dg(m, n)); } } return 0; }