题目

Solution

1.题解
2.我们班长给出的证明(举例中的I=6):
洛谷P2767 树的数量
洛谷P2767 树的数量
洛谷P2767 树的数量

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=23333;
int x,y;
ll n,m;
void ex_gcd(int a,int b,int &x,int &y){
	if (!b) x=1,y=0;
	else ex_gcd(b,a%b,y,x),y-=a/b*x;
}
int C(ll n,ll m){
	if (n<m) return 0;
	if (n>=M) return C(n/M,m/M)*C(n%M,m%M)%M;
	int ans=1;
	for (int i=n-m+1;i<=n;i++) ans=ans*i%M;
	for (int i=2;i<=m;i++) ex_gcd(i,M,x,y),ans=ans*(x+M)%M;
	return ans;
}
int main(){
	scanf("%lld%lld",&n,&m);
	ex_gcd(n,M,x,y);
	printf("%d",((x+M)*C(n*m,n-1)+1)%M);
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
  • 2022-12-23
  • 2021-08-16
  • 2022-02-08
  • 2021-05-24
猜你喜欢
  • 2021-07-05
  • 2021-12-16
  • 2021-08-11
  • 2022-12-23
  • 2021-12-16
  • 2022-12-23
相关资源
相似解决方案