题解 | #放苹果#
放苹果
https://www.nowcoder.com/practice/a2a1d0266629404fba582d416d84b6a0
#include <iostream> #include <algorithm> using namespace std; int dp[22]; int main() { int m, n; while (cin >> m >> n) { fill_n(dp, 22, 0); dp[0] = 1; for (int i = 1; i <= n; i++) { for (int j = i; j <= m; j++) { dp[j] = dp[j] + dp[j - i]; } } cout << dp[m] << endl; } }