提交时间:2023-08-24 10:19:36
运行 ID: 99909
#include <bits/stdc++.h> using namespace std; int cnt,n,m; void dfs(int p, int tot, int tmp) { if(tot==n&&p>m) { cnt++; return; } if(tot>=n||p>m)return; for(int i = tmp; i <= n; i++) { dfs(p+1,tot+i,max(tmp,i)); } } signed main() { int T; cin >> T; while(T--) { cin >> n >> m; cnt = 0; dfs(1,0,0); cout << cnt << endl; } return 0; }