diff --git a/src/math/count_of_integers.cpp b/src/math/count_of_integers.cpp index 4ca7c9b..490175f 100644 --- a/src/math/count_of_integers.cpp +++ b/src/math/count_of_integers.cpp @@ -17,23 +17,23 @@ class Solution { for (char c : num1) down_limit.push_back(c - '0'); - std::function f; + std::function f; std::unordered_map memo; - f = [&](int i, int s, bool valid, bool dlimit, bool ulimit) -> int { + f = [&](int i, long long s, bool valid, bool dlimit, bool ulimit) -> int { if (i == m) { return valid && min_sum <= s && s <= max_sum ? 1 : 0; } long long key = - i + 71LL * (s + 71LL * (valid + 2LL * (dlimit + 2LL * ulimit))); + i + 1001LL * (s + 1001LL * (valid + 2LL * (dlimit + 2LL * ulimit))); if (memo.count(key)) return memo[key]; int down = dlimit ? down_limit[i] : 0; int up = ulimit ? up_limit[i] : 9; int ans = 0; for (int d = down; d <= up; ++d) { - ans = (ans + f(i + 1, s + d, valid || d != 0, dlimit && d == down, - ulimit && d == up)) % + ans = (ans + f(i + 1, (s + d) % mod, valid || d != 0, + dlimit && d == down, ulimit && d == up)) % mod; } return memo[key] = ans; diff --git a/test/lib/lib_test.cpp b/test/lib/lib_test.cpp index c66cc93..32f5686 100644 --- a/test/lib/lib_test.cpp +++ b/test/lib/lib_test.cpp @@ -1,4 +1,4 @@ -// 执行编译时间:2024-01-16 09:18:43 +// 执行编译时间:2024-01-16 09:32:34 #include #include