提交时间:2023-10-05 10:48:10
运行 ID: 105120
#include<bits/stdc++.h> #define int long long using namespace std; int m,n,a[35],ans; void dfs(int x){ if(m<a[x-1]){ return; } if(x==n){ ans++; return; } for(int i=a[x-1];i<=m;i++){ a[x]=i; m-=i; dfs(x+1); m+=i; } } signed main(){ int s; cin>>s; while(s--){ memset(a,0,sizeof(a)); ans=0; cin>>m>>n; dfs(1); cout<<ans<<endl; } return 0; }