标程

rdsrgssh 2020-08-06 14:44:15 17 返回题目

#include<bits/stdc++.h>
using namespace std;
int m,n,ans,f[110][110];
int main()
{
	int t;
	cin >> t;
	while(t--)
	{
		cin >> m >> n;
		ans=0;
		memset(f,0,sizeof(f));
		for(int i=1;i<=n;i++)
			f[0][i]=f[1][i]=1; 
		for(int i=1;i<=m;i++)
			f[i][1]=1;
		for(int i=2;i<=m;i++)
			for(int j=2;j<=n;j++)
				if(i<j)
					f[i][j]=f[i][i];
				else
					f[i][j]=f[i-j][j]+f[i][j-1];
		cout << f[m][n] << endl;
	}
	return 0;
}
{{ vote && vote.total.up }}

共 6 条回复

heyucheng
heyucheng
071lizhenxuan

很奇怪

071lizhenxuan

有时会超时,有时不会

ixzhangbaop

ts

std

👍🏻