HDOJ 2049 不容易系列之(4)——考新郎
2014-07-16 10:36
246 查看
一道错排题,照着公式来撸……
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
int main()
{
long long a[21]={1,1,2};
long long b[21]={0,0,1};
for(int i=3;i<=20;i++)
{
a[i]=a[i-1]*i;
b[i]=(i-1)*(b[i-1])+b[i-2];
}
int t,n,m;
cin>>t;
while(t--)
{
cin>>n>>m;
printf("%I64d\n",a
*b[m]/a[m]/a[n-m]);
}
return 0;
}
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
int main()
{
long long a[21]={1,1,2};
long long b[21]={0,0,1};
for(int i=3;i<=20;i++)
{
a[i]=a[i-1]*i;
b[i]=(i-1)*(b[i-1])+b[i-2];
}
int t,n,m;
cin>>t;
while(t--)
{
cin>>n>>m;
printf("%I64d\n",a
*b[m]/a[m]/a[n-m]);
}
return 0;
}
相关文章推荐
- hdoj 2049 不容易系列之(4)——考新郎
- HDOJ 2049 不容易系列之(4)——考新郎
- hdoj 2049 不容易系列之(4)——考新郎
- hdoj 2049 不容易系列之(4)——考新郎
- hdoj 2049 不容易系列之(4)——考新郎 【排列组合+全排列】
- HDOJ 2049 不容易系列之(4)——考新郎(排列组合+错排公式)
- HDOJ, 杭电2049, 不容易系列之(4)——考新郎。。。组合加错排。
- HDOJ 题目2049 不容易系列之(4)——考新郎(部分错排)
- HDOJ 不容易系列之(4)——考新郎 2049(错排)
- hdoj-2049-不容易系列之(4)——考新郎
- hdoj 2049 不容易系列之(4)——考新郎
- hdoj-2049-不容易系列之(4)——考新郎
- hdoj_2049 不容易系列之(4)——考新郎
- hdoj 2049 不容易系列之(4)——考新郎 【全错位排列】【组合数】
- hdoj-2049(不容易系列之(4)——考新郎)(全错位排列+排列组合)
- HDOJ2049 不容易系列之(4)——考新郎
- HDOJ 2049-不容易系列之(4)——考新郎【错排】
- HDOJ 2049 不容易系列之(4)——考新郎
- hdoj 不容易系列之(4)——考新郎 2049 (错排)
- hdoj.2049 不容易系列之(4)——考新郎 20140805