// #include <stdio.h> // int main() { // int n; // scanf("%d", &n); // int shuzu[n]; // if (n >= 1) shuzu[0] = 0; // if (n >= 2) shuzu[1] = 1; // if (n >= 3) shuzu[2] = 1; // if (n == 1){ // printf("%d", shuzu[0]); // } // if ((n == 2) || (n == 3)){ // printf("%d", shuzu[1]); // } // if (n >= 4){ // for (int i = 3; i < n; i++){ // shuzu[i] = shuzu[i - 3] + 2 * shuzu[i - 2] + shuzu[i - 1]; // } // } // printf("%d", shuzu[n - 1]); // return 0; // } //更简便的写法 #include <stdio.h> int main(){ int n; scanf("%d", &n); int a = 0, b = 1, c = 1, d; if (n == 1){ printf("%d", a); return 0; } if (n == 2 || n == 3){ printf("%d", b); return 0; } for(int i = 4; i <= n; i++){ d = c + 2 * b + a; a = b; b = c; c = d; } printf("%d", c); return 0; }