M3TILE - LATGACH3

Tác giả: happyboy99x

Ngôn ngữ: C++

#include<cstdio>

int f[31], g[31];

int main() {
	f[0] = 1; f[1] = 0; g[0] = 0; g[1] = 1;
	for(int i = 2; i <= 30; ++i) {
		f[i] = f[i-2] + 2*g[i-1];
		g[i] = f[i-1] + g[i-2];
	}
	int n;
	while(scanf("%d", &n) != EOF && n != -1) printf("%d\n", f[n]);
	return 0;
}

Download