#include <iostream>
using namespace std;
long long d[31];
void dp() {
for (int i = 4; i < 31; i += 2) {
d[i] = 3 * d[i - 2]; // i)3个块组成独立矩形
// ii)不可垂直分割,作为整体,方案数累加
for (int j = 0; j <= i - 4; j += 2)
d[i] += 2 * d[j];
}
}
int main(int argc, char **argv) {
int n;
// 递推起点
d[0] = 1;
d[2] = 3;
while (cin >> n && n != -1) {
if (n % 2)
cout << 0 << endl;
else {
dp();
cout << d[n] << endl;
}
}
return 0;
}
#include <iostream>
using namespace std;
long long d[31];
int main(int argc, char **argv) {
int n;
// 解递推式f(n) = 3f(n-2) + 2(f(n-4) + f(n-6) + ... + f(0))得f(n) = 4f(n-2) - f(n-4), 思路更清晰
d[0] = 1;
d[2] = 3;
for (int i = 4; i < 31; ++i)
d[i] = 4 * d[i - 2] - d[i - 4];
while (cin >> n && n != -1) {
if (n % 2)
cout << 0 << endl;
else
cout << d[n] << endl;
}
return 0;
}