题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1005
纸上画一下,找了一下规律,Ank*Cnk.
//#pragma comment(linker, "/STACK:102400000, 102400000")
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long LL;
typedef pair <int, int> P;
const int N = 1e5 + ; LL Anm(LL n, LL m) {
LL ans = ;
for(LL i = n; i >= n - m + ; --i) {
ans = ans * i;
}
return ans;
} int main()
{
int t;
LL n, k;
scanf("%d", &t);
for(int ca = ; ca <= t; ++ca) {
scanf("%lld %lld", &n, &k);
printf("Case %d: ", ca);
if(k > n) {
printf("0\n");
continue;
}
LL ans = Anm(n, k);
LL temp = ans;
for(LL i = k; i >= ; --i) {
temp /= i;
}
printf("%lld\n", ans * temp);
}
return ;
}