// u代表dfs到了哪一位,s代表已经用了多少查克拉,st就是start的缩写代表着从多少开始,因为本题总不考虑顺序,所以我们自己规定一个不减小的顺序 voiddfs(int u, int s, int st) { if (s > n) return; // 剪枝,如果大于查克拉总量 return if (u == m + 1) // 找完所有位 { if (s == n) ans++; return; } for (int i = st; i <= n; i++) { f[u] = i; dfs(u + 1, s + i, i); } }
intmain() { int t; cin >> t; while (t--) { cin >> n >> m; dfs(1, 0, 0); cout << ans << endl; ans = 0; } return0; }