0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-19 22:05:24 +00:00

2411. Mondriaan's Dream

23522528
This commit is contained in:
Baoshuo Ren 2022-05-27 11:59:26 +08:00
parent a5450ff656
commit 691b82df12
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

48
POJ/2411/2411.cpp Normal file
View File

@ -0,0 +1,48 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
int n, m;
long long f[12][1 << 11];
bool g[1 << 11];
int main() {
std::ios::sync_with_stdio(false);
while (cin >> n >> m, n || m) {
for (int i = 0; i < 1 << m; i++) {
bool cnt = false,
has_odd = false;
for (int j = 0; j < m; j++) {
if (i >> j & 1) {
has_odd |= cnt;
cnt = false;
} else {
cnt ^= true;
}
}
g[i] = !(has_odd | cnt);
}
f[0][0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 0; j < 1 << m; j++) {
f[i][j] = 0;
for (int k = 0; k < 1 << m; k++) {
if (!(j & k) && g[j | k]) {
f[i][j] += f[i - 1][k];
}
}
}
}
cout << f[n][0] << endl;
}
return 0;
}