HDU/2047/main.c

19 lines
434 B
C
Raw Normal View History

2020-08-31 16:48:58 +00:00
#include <stdio.h>
int main(void){
int count,i;
unsigned long long n[3][40]={0};
n[0][0] = 1, n[1][0] = 1, n[2][0] = 1;
n[0][1] = 3, n[1][1] = 2, n[2][1] = 3;
for(i = 2; i < 40; i++){
n[0][i] = n[0][i-1] + n[1][i-1] + n[2][i-1];
n[1][i] = n[0][i-1] + n[2][i-1];
n[2][i] = n[0][i-1] + n[1][i-1] + n[2][i-1];
}
while(scanf("%d",&count) == 1){
printf("%llu\n",n[0][count-1]+n[1][count-1]+n[2][count-1]);
}
return 0;
}