提交时间:2023-10-05 22:35:45
运行 ID: 105267
#include<bits/stdc++.h> #define int long long using namespace std; namespace Fast{ inline int fr(){ int x = 0,f = 1; char c = getchar(); while (c < '0' || c > '9'){ if (c == '-'){ f = -1; } c = getchar(); } while (c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void fw(int x){ if (x < 0){ x = -x; putchar('-'); } if (x > 9){ fw(x / 10); } putchar(x % 10 + 48); } } using namespace Fast; int ret[35],n,m,sum; void dfs(int cur,int s,int lstnum){ if (cur == n && s == m){ sum++; return ; } if (cur >= n || s > m){ return ; } for (int i = lstnum;i <= m;i++){ dfs(cur + 1,s + i,i); } } void slove(){ m = fr(),n = fr(); sum = 0; dfs(0,0,0); fw(sum); puts(""); } signed main(){ int t = fr(); while (t--){ slove(); } return 0; }