Skip to content

Commit 1750492

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d59efbc commit 1750492

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

solutions/gold/cf-100886G.mdx

+6-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ If $l = 1$, what will the best solution always be?
1010
</Spoiler>
1111
## Explanation
1212
### $l = 1$
13-
Let's start with an example: $l = 1$ and $r = 875$. Observe that we really need to consider three numbers as viable answers: $875$, $799$, and $869$. Try to think about why, and how this generalizes!
13+
Let's start with an example: $l = 1$ and $r = 875$. Observe that we really need to consider three numbers as viable answers: $875$, $799$, and $869$. Try to think about why, and how this generalizes!
1414
### $l \neq 1$
1515
We can apply a very similar approach when $l \neq 1$. In fact, it's almost identical, with one minor difference. Consider the case where $l = 855$ and $r = 875$, just as before. The only difference is we can no longer consider $799$ as a viable answer, as it is less than $l$. Again, try to think about how to generalize this!
1616

@@ -43,15 +43,15 @@ int main() {
4343
while (l.length() < r.length()) { l.insert(l.begin(), '0'); }
4444
string ans = "";
4545
// i -> length of LCP (longest common prefix) of str and r
46-
bool eq = true; // whether l[0, i) = r[0, i)
46+
bool eq = true; // whether l[0, i) = r[0, i)
4747
for (int i = 0; i <= r.length(); i++) {
4848
string cur = r.substr(0, i);
4949
eq = eq && l[i] == r[i];
5050
/*
51-
* in this case, str[i] must equal r[i]
52-
* and now the shared prefix has length i + 1
53-
* which contradicts our assumption that the LCP has length i
54-
*/
51+
* in this case, str[i] must equal r[i]
52+
* and now the shared prefix has length i + 1
53+
* which contradicts our assumption that the LCP has length i
54+
*/
5555
if (i < r.length() && eq) { continue; }
5656
if (i < r.length()) { cur += char(r[i] - 1); }
5757
// fill remaining digits with 9's
@@ -62,7 +62,6 @@ int main() {
6262
while (ans[0] == '0') { ans.erase(ans.begin()); }
6363
cout << ans << endl;
6464
}
65-
6665
```
6766
6867
</CPPSection>

0 commit comments

Comments
 (0)