// yukicoder: No.533 Mysterious Stairs // 2019.7.26 bal4u // For n>6, a(n) = a(n-3) + a(n-4) + a(n-5) + 2*a(n-6). (End) #include #define MOD 1000000007 unsigned a[1000005] = {1,1,1,3,3,4,8,9,12,21,27}; int main() { int i, N; unsigned k; scanf("%d", &N); if (N <= 10) k = a[N]; else { for (i = 11; i <= N; i++) a[i] = ((long long)a[i-3] + a[i-4] + a[i-5] + (a[i-6]<<1)) % MOD; k = a[N]; } printf("%u\n", k); return 0; }