///UVA580CriticalMass
#include<cstdio>
#include<cstring>
const int maxn = 30;
int f[maxn + 5], g[maxn + 5];
int main() {
f[0] = f[1] = f[2] = 0;
g[0] = 1 << 0; g[1] = 1 << 1; g[2] = 1 << 2;
for(int n = 3; n <= maxn; n++) {
f[n] = 1 << (n - 3);//当i等于1时
for(int i = 2; i <= n - 2; i++) f[n] += g[i - 2] * (1 << (n - i - 2));//累加当i不等于1时的所有情况
g[n] = (1 << n) - f[n];//计算g(n),即没有三个U放在一起的前n个盒子的方案
}
int n;
while(scanf("%d", &n) == 1 && n) printf("%d\n", f[n]);
return 0;
}
/*
4
5
0
*/
09-06
683
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-10
417
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-04
811
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-13
325
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-25
647
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-12
689
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)