/* -*- coding: utf-8 -*- * * 741.cc: No.741 AscNumber(Easy) - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 1000000; const int D = 10; const int MOD = 1000000007; /* typedef */ typedef long long ll; typedef int vec[D]; typedef vec mat[D]; /* global variables */ const mat MM = {{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1, 1, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, }; const vec VV = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; mat ma, mb, mc; vec va, vb, vc; /* subroutines */ inline void initvec(vec a) { fill(a, a + D, 0.0); } inline void initmat(mat a) { for (int i = 0; i < D; i++) initvec(a[i]); } inline void unitmat(mat a) { initmat(a); for (int i = 0; i < D; i++) a[i][i] = 1; } inline void copymat(const mat a, mat b) { memcpy(b, a, sizeof(mat)); } inline void addmat(const mat a, const mat b, mat c) { for (int i = 0; i < D; i++) for (int j = 0; j < D; j++) c[i][j] = (a[i][j] + b[i][j]) % MOD; } inline void mulmat(const mat a, const mat b, mat c) { for (int i = 0; i < D; i++) for (int j = 0; j < D; j++) { c[i][j] = 0; for (int k = 0; k < D; k++) c[i][j] = (c[i][j] + (ll)a[i][k] * b[k][j] % MOD) % MOD; } } inline void powmat(const mat a, int b, mat c) { mat s, t; copymat(a, s); unitmat(c); while (b > 0) { if (b & 1) { mulmat(c, s, t); copymat(t, c); } mulmat(s, s, t); copymat(t, s); b >>= 1; } } inline void mulmatvec(const mat a, const vec b, vec c) { for (int i = 0; i < D; i++) { c[i] = 0; for (int j = 0; j < D; j++) c[i] = (c[i] + (ll)a[i][j] * b[j] % MOD) % MOD; } } void printvec(const vec a) { for (int j = 0; j < D; j++) { if (j) putchar(' '); printf("%d", a[j]); } putchar('\n'); } void printmat(const mat a) { for (int i = 0; i < D; i++) printvec(a[i]); } /* main */ int main() { int n; scanf("%d", &n); powmat(MM, n, ma); mulmatvec(ma, VV, va); int sum = 0; for (int i = 0; i < D; i++) sum = (sum + va[i]) % MOD; printf("%d\n", sum); return 0; }