func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 30;   const int maxn = 105;   const int MOD = 1e9 + 7;   const double eps = 1e-6;   const double pi = acos(-1);   long long n, m;   long long T[maxn][maxn];   long long f[maxn];   void Mul_mat(long long fin[][maxn], long long b[][maxn]) {     long long ans[maxn][maxn];     for (int i = (0); i < (m); ++i)       for (int j = (0); j < (m); ++j) ans[i][j] = 0;     for (int i = (0); i < (m); ++i)       for (int j = (0); j < (m); ++j)         for (int k = (0); k < (m); ++k) {           ans[i][j] = (ans[i][j] + fin[i][k] * b[k][j]) % MOD;         }     for (int i = (0); i < (m); ++i)       for (int j = (0); j < (m); ++j) fin[i][j] = ans[i][j];   }   void Pow_mat(long long n, long long fin[][maxn], long long b[][maxn]) {     long long ans[maxn][maxn];     for (int i = (0); i < (m); ++i)       for (int j = (0); j < (m); ++j) {         if (i != j)           ans[i][j] = 0;         else           ans[i][j] = 1;       }     while (n) {       if (n & 1) Mul_mat(ans, b);       Mul_mat(b, b);       n >>= 1;     }     memcpy(fin, ans, sizeof(ans));   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     while (cin >> n >> m) {       if (n < m) {         cout << 1 << endl;         continue;       }       memset(T, 0, sizeof(T));       for (int i = (0); i < (m - 1); ++i) T[i][i + 1] = 1;       T[m - 1][0] = T[m - 1][m - 1] = 1;       long long f[maxn];       for (int i = (0); i < (m - 1); ++i) f[i] = 1;       f[m - 1] = 2;       long long tmp[maxn][maxn];       memset(tmp, 0, sizeof(tmp));       Pow_mat(n - 1, tmp, T);       long long ans = 0;       for (int i = (0); i < (m); ++i) {         ans = (ans + tmp[0][i] * f[i]) % MOD;       }       cout << ans << endl;     }     return 0;   }   