题解 | #放苹果#
放苹果
https://www.nowcoder.com/practice/bfd8234bb5e84be0b493656e390bdebf
#include <bits/stdc++.h> using namespace std; // 采用递归的话 int myfun(int m, int n) { if(n==1) { return 1; } if(m==0) { return 1; } int ans = 0; if(m<n) { ans = myfun(m,m); } else { ans = myfun(m, n-1) + myfun(m-n, n); } return ans; } int main() { int m, n; while (cin >> m >> n) { // 注意 while 处理多个 case cout<<myfun(m, n)<<endl; } } // 64 位输出请用 printf("%lld")