序列 (组合数)

https://www.nowcoder.com/acm/contest/129/A

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int maxn=1000+10;
LL mod =1e9+7;
LL comb[1010][1010];
void init()
{
	for(int i=0;i<maxn;i++)
	{
		comb[i][0]=comb[i][i]=1;
		for(int j=1;j<i;j++)
		{
			comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
			comb[i][j]%=mod;
		}
	}
}
int main()
{
	init();
	int n;
	scanf("%d",&n);
	n--;
	long long ans=0;
	for(int i=0;i<=n/4;i++)
	{
		ans=ans+comb[n][2*i]%mod*comb[n-2*i][2*i]%mod;
		ans=ans%mod;
	}
	printf("%lld\n",ans);
	return 0;
}

猜你喜欢

转载自blog.csdn.net/liuliu2333/article/details/80782043