ref
真是道组合数学神题啊……第一次见第一类斯特林数……

#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
int T, n, a, b, s[50005][205], c[205][205];
const int mod=1e9+7;
int main(){
	for(int i=0; i<=50000; i++){
		if(i<=200)	s[i][i] = 1;
		for(int j=1; j<=min(i-1, 200); j++)
			s[i][j] = (s[i-1][j-1] + (ll)s[i-1][j]*(i-1)%mod) % mod;
	}
	for(int i=0; i<=200; i++){
		c[i][0] = 1;
		for(int j=1; j<=i; j++)
			c[i][j] = (c[i-1][j-1] + c[i-1][j]) % mod;
	}
	cin>>T;
	while(T--){
		scanf("%d %d %d", &n, &a, &b);
		printf("%d\n", (ll)s[n-1][a+b-2]*c[a+b-2][a-1]%mod);
	}
	return 0;
}

相关文章:

  • 2021-07-25
  • 2021-08-01
  • 2021-11-10
  • 2021-10-06
  • 2021-11-10
  • 2021-11-06
  • 2021-10-04
  • 2021-04-13
猜你喜欢
  • 2021-08-24
  • 2022-12-23
  • 2021-12-11
  • 2021-11-11
  • 2022-12-23
  • 2021-06-28
  • 2021-11-16
相关资源
相似解决方案