#define N 4
/*
* 公式:
* f(n) = 2^((n - 1) ^2) */
int calWays(int n) {
int mutiNum = (n - 1) * (n - 1);
int result = 1;
for (int i = 0; i < mutiNum / 2; ++i) {
result *= 2;
}
result *= result;
if (mutiNum % 2) {
result *= 2;
}
return result;
}
等价于n*n的矩阵,填写0,1,要求每行每列的都有偶数个1 (没有1也是偶数个),问有多少种方法。
最新推荐文章于 2022-03-15 14:36:15 发布