题目大意:
n∗n
网格中方
k
个车,使得每行每列最多只有
分析:
很明显答案就是
Ckn∗Akn
。
AC code:
#include <cstdio>
#include <iostream>
typedef long long LL;
#define ONLINE_JUDGE
const int MAXN = 19;
int n, k;
LL work()
{
if(k > n) return 0;
LL ret = 1;
for(int i = n, j = 1; j <= k; --i, ++j)
{
ret *= i*i;
ret /= j;
}
return ret;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("sgu222.in", "r", stdin);
freopen("sgu222.out", "w", stdout);
#endif
std::ios::sync_with_stdio(0);
std::cin >> n >> k;
std::cout << work() << std::endl;
#ifndef ONLINE_JUDGE
fclose(stdin);
fclose(stdout);
#endif
return 0;
}