func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mo = 1e9 + 7;   char s[2010], ss[2010];   long long dp[2010][2010], a[2010];   long long m, d, jo;   int len;   long long dfs(int pos, long long sum, bool limit) {     if (pos == len) return sum == 0;     if (!limit && dp[pos][sum] != -1) return dp[pos][sum];     int up = limit ? a[pos] : 9;     long long tmp = 0;     for (int i = 0; i <= up; i++) {       if (pos & 1) {         if (i == d)           tmp =               (tmp + dfs(pos + 1, (sum * 10 + i) % m, limit && i == a[pos])) % mo;       } else if (i != d)         tmp = (tmp + dfs(pos + 1, (sum * 10 + i) % m, limit && i == a[pos])) % mo;     }     if (!limit) dp[pos][sum] = tmp;     return tmp;   }   int solve(char *s) {     int pos = strlen(s) - 1;     len = 0;     while (len <= pos) {       a[len] = s[len] -  0 ;       len++;     }     long long as = dfs(0, 0, true);     return as;   }   int main() {     int le, ri;     while (scanf( %lld%lld , &m, &d) != EOF) {       memset(dp, -1, sizeof(dp));       scanf( %s%s , s, ss);       int l = strlen(s);       long long spc = 1, sm = 0;       for (int i = 0; i < l; i++) {         if ((i % 2 == 0) && ((s[i] & 15) == d)) {           spc = 0;           break;         } else if ((i & 1) && ((s[i] & 15) != d)) {           spc = 0;           break;         }         sm = (sm * 10 + (s[i] & 15)) % m;       }       if (spc) spc = (sm == 0);       printf( %lld n , (solve(ss) - solve(s) + spc + mo) % mo);     }     return 0;   }   