TJ
2024-08-19 17:29:28
发布于:浙江
14阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
int dp[20][20];
int t , m , n;
cin >> t;
while ( t-- ){
memset ( dp , 0 , sizeof ( dp ));
cin >> m >> n;
for ( int i = 0; i <= n; i++ ){
dp[0][i] = 1;
dp[1][i] = 1;
}
for ( int i = 0; i <= m; i++ ){
dp[i][0] = 0;
dp[i][1] = 1;
}
for ( int i = 2; i <= m; i++ ){
for ( int j = 2; j <= n; j++ ){
if ( i < j ) dp[i][j] = dp[i][i];
else dp[i][j] = dp[i - j][j] + dp[i][j - 1];
}
}
cout << dp[m][n] <<endl;
}
return 0;
}
这里空空如也
有帮助,赞一个