`
tulunta
  • 浏览: 356770 次
文章分类
社区版块
存档分类
最新评论

A C&&http://acm.hdu.edu.cn/showproblem.php?pid=1570

 
阅读更多

杨辉三角与二项式定理的应用~~~~不解释。。。。。

AC代码:

#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#define N 11
using namespace std;
int dp[N][N];
int ss[N]={0,1,2,6,24,120,720,5040,40320,362880,3628800};
void init()
{
	memset(dp,0,sizeof(dp));
	for(int i=0;i<N;++i)
	{   
		dp[i][0]=1;
		for(int j=1;j<=i;++j)
			dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
	}
}
int main()
{
	int T;
	scanf("%d",&T);
	init();
	while(T--)
	{
		char s[2];
		scanf("%s",s);
		int m,n;
		scanf("%d%d",&n,&m);
		if(s[0]=='A') printf("%d\n",dp[n][m]*ss[m]);
		else if(s[0]=='C')   printf("%d\n",dp[n][m]); 
		}return 0;
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics