A C&&http://acm.hdu.edu.cn/showproblem.php?pid=1570
2012-07-10 15:37
417 查看
杨辉三角与二项式定理的应用~~~~不解释。。。。。
AC代码:
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#define N 11
using namespace std;
int dp
;
int ss
={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
[m]*ss[m]);
else if(s[0]=='C') printf("%d\n",dp
[m]);
}return 0;
}
AC代码:
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#define N 11
using namespace std;
int dp
;
int ss
={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
[m]*ss[m]);
else if(s[0]=='C') printf("%d\n",dp
[m]);
}return 0;
}
相关文章推荐
- Robberies&&http://acm.hdu.edu.cn/showproblem.php?pid=2955
- http://acm.hdu.edu.cn/showproblem.php?pid=1020&&encoding
- http://acm.hdu.edu.cn/webcontest/contest_showproblem.php?cid=963&pid=1019&ojid=1
- Text Reverse&&http://acm.hdu.edu.cn/showproblem.php?pid=1062
- Number Sequence&&http://acm.hdu.edu.cn/showproblem.php?pid=1005
- A + B Problem II &&http://acm.hdu.edu.cn/showproblem.php?pid=1002
- http://acm.hdu.edu.cn/webcontest/contest_showproblem.php?pid=1004&ojid=1&cid=6866&hide=1&problem=Pro
- Buy the Ticket&&http://acm.hdu.edu.cn/showproblem.php?pid=1133
- The 36th ACM/ICPC Asia Regional Beijing Site&&http://acm.hdu.edu.cn/showproblem.php?pid=4046
- 二分查找求函数的区间最小值&&http://acm.hdu.edu.cn/showproblem.php?pid=2899
- 导弹拦截二&&http://acm.hdu.edu.cn/showproblem.php?pid=1257
- HDU Today&&http://acm.hdu.edu.cn/showproblem.php?pid=2112
- Happy 2004&&http://acm.hdu.edu.cn/showproblem.php?pid=1452
- Red and Black&&http://acm.hdu.edu.cn/showproblem.php?pid=1312
- Max Sum &&http://acm.hdu.edu.cn/showproblem.php?pid=1003
- http://acm.hdu.edu.cn/showproblem.php?pid=1055&&Color a Tree
- To The Max &&http://acm.hdu.edu.cn/showproblem.php?pid=1081
- Substrings &&http://acm.hdu.edu.cn/showproblem.php?pid=1238
- I NEED A OFFER! &&http://acm.hdu.edu.cn/showproblem.php?pid=1203
- Trouble&&http://acm.hdu.edu.cn/showproblem.php?pid=4334