#include #include #include #define MAX_SUM 1800 #define MAX_DIGIT 205 int mod = 1000000009; int len = 0; int s_max = 0; int M_count[MAX_SUM] = {0}; int D_count[MAX_SUM] = {0}; void DpFunk(const char* str, int* count, int digit, bool tight, int sum){ if(digit == len){ if(sum > 0) ++count[sum - 1]; if(sum > s_max) s_max = sum; return; } int x = str[digit] - '0'; int r = (tight ? x : 9); for(int i = 0; i <= r; ++i){ DpFunk(str, count, digit + 1, tight && i == r, sum + i); } return; } int main(void){ char M_str[MAX_DIGIT] = {0}; char D_str[MAX_DIGIT] = {0}; scanf("%s", M_str); scanf("%s", D_str); len = strlen(M_str); DpFunk(M_str, M_count, 0, true, 0); int roop = s_max; len = strlen(D_str); DpFunk(D_str, D_count, 0, true, 0); if(roop > s_max) roop = s_max; int i; long long int count = 0; for(i = 0; i < roop; ++i){ count += (M_count[i] * D_count[i]); count %= mod; } printf("%lld\n", count); return 0; }