From e404d0f0024186cc634c1f18b200ec4fd26170ec Mon Sep 17 00:00:00 2001 From: yi-ge Date: Tue, 16 Jan 2024 09:32:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BB=9F=E8=AE=A1=E6=95=B4=E6=95=B0?= =?UTF-8?q?=E6=95=B0=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/math/count_of_integers.cpp | 10 +++++----- test/lib/lib_test.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) 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