提交时间:2024-04-16 16:46:25
运行 ID: 143565
#include<bits/stdc++.h> using namespace std; int t,n,m,ans,a[100001]; void dfs(int step,int sum,int minn){ if(sum==n&&step>m){ ans++; return; } if(sum>=n||step>m)return; for(int i=minn;i<=n;i++){ a[step]=i; dfs(step+1,sum+i,max(minn,i)); a[step]=0; } } int main(){ cin>>t; while(t--){ ans=0; cin>>n>>m; dfs(1,0,0); cout<<ans<<endl; } return 0; }