杭电acm2047

#include <stdio.h>
#include <math.h>

int main() {
	
	int n, i;
	__int64 d[40][2]={ {1, 2} };
	
	/*d[i][0] indicate the sequence's last char is not O
		d[i][1] opposite*/
	for(i=1; i<40; i++) {
		d[i][0] = d[i-1][1];
		d[i][1] = 2 * d[i-1][0] + 2 * d[i-1][1];
	}

	while(~scanf("%d", &n)) {
		printf("%I64d\n", d[n-1][0] + d[n-1][1]);
	}
	
	return 0;
}

posted @ 2015-03-13 22:24  StevenLuke  阅读(120)  评论(0编辑  收藏  举报