#include <iostream>
using namespace std;
int main()
{
int c,i,j;
int m,n;
long long sm [21]; // The result of misalignment of m elements
long long a[21];
sm[0]=1;
sm[1]=0;
a[0]=1;
a[1]=1;
for(j=2;j<21;j++){
sm[j]=(j-1)*(sm[j-1]+sm[j-2]);
a[j]=j*a[j-1];
}
cin>>c;
for(i=0;i<c;i++){
cin>>n>>m;
cout<<sm[m]*(a[n]/a[m]/a[n-m])<<endl;
}
return 0;
}
【postscript】
1. The reason is very simple. The combination number C (n, m) multiplied by m elements is staggered, but infinite WA is a bit painful. .
Problem Description As the old man Xu had no money, the toll collector took half of his sheep and hesitated after seeing the old man tears, and returned one to the old man. Coincidentally, for each to...
Not easy series (4) - test groom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 50993 Accepted Submission(s): 18596 Problem Description During th...
Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. http://xiang578.top/...
Problem Description During the National Day, the provincial capital HZ just held a grand mass wedding, the wedding of the rich in order to make some temporary master of ceremonies has come up with an ...
Not easy Series (4) - test Groom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 46965 Accepted Subm...
hdu 2044 Click to open the link a[0]=1;a[1]=1 a[i]=a[i-1]+a[i-2] Fibonacci hdu 2045 Click to open the link 1. The n-1 grid and the 1st grid have different colors a [i] = a [i-1] 2. The n-1 cell and th...
Original title:http://acm.hdu.edu.cn/showproblem.php?pid=2092 Divided into five situations, a lot of duplicate code, too lazy to change...
1. Which of the following descriptions of forward and redirect is correct (BCD)? A forward means that the server transfers control to another internal server object, and the new object is fully respon...
Original title link:http://acm.hdu.edu.cn/showproblem.php?pid=2068 Reference 1: Staggered formula explanation: Reference 2: Title Code:...
Problem Description A Niu brought a piece of superior beef jerky from home and was going to engrave a string of length n consisting of only three characters "E" "O" "F" C...