Thinking
Consider the first \ (n-\) bit \ (F. \) Or \ (E \) , the first \ (n - 1 \) bits, can fill \ (3 \) letters, \ (F [n-] =. 1 * 2f [n-1] \)
Consider the first \ (n-\) bit \ (O \) , because the two \ (O \) not adjacent, the first \ (n- 1 \) bit, only fill \ (2 \) letters, The first \ (n-2 \) can fill \ (3 \) letter
\(f[n]=1*2*f[n-2]\)
Total answer is \ (f [n] = 2 (f [n-1] + f [n-2]) \)
#include <bits/stdc++.h>
using namespace std;
const int N = 100;
typedef long long LL;
LL f[N] = {0,3,8},k = 2;
int main() {
int n;
while(cin >> n) {
if(n > k) {
while(k <= n) {
k ++;
f[k] = (f[k - 1] + f[k - 2]) * 2;
}
}
cout << f[n] << endl;
}
return 0;
}