Skip to content

Commit bd6971a

Browse files
committed
test pre-commit
1 parent f2406e9 commit bd6971a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

solutions/bronze/cses-2431.mdx

+10-10
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ the group. For instance:
2727
$\rightarrow3\cdot900=2700$ digits total
2828
- And so on...
2929

30-
To find which group the number that contains the $k$-th digit is in, we can
30+
To find which group the number that contains the $k$th digit is in, we can
3131
iterate through groups until the sum of the total number of digits from all the
3232
groups we've processed becomes greater than or equal to $k$. In other words, we
3333
continue increasing the number of groups we look at (starting from $1$-digit
@@ -37,8 +37,8 @@ $$
3737
\sum^{\text{\# of groups}}_{n=1}{n\cdot9\cdot10^{n-1}\geq k}
3838
$$
3939

40-
Once the condition becomes true, we know that the $k$-th digit must fall into
41-
the last group used in the sum. We can now calculate the $k$-th digit's position
40+
Once the condition becomes true, we know that the $k$th digit must fall into
41+
the last group used in the sum. We can now calculate the $k$th digit's position
4242
in the group by subtracting $k$ by the total number of digits from all groups
4343
before it. We'll call this relative position $j$:
4444

@@ -48,15 +48,15 @@ $$
4848

4949
Note that we subtract $1$ from the result in order to make $j$ $0$-based (which
5050
makes it more convenient to solve the rest of the problem). For example, if
51-
$j=0$, that would mean the $k$-th digit is the first digit in the group. If
52-
$j=100$, that would mean the $k$-th digit is the $99$-th digit in the group,
51+
$j=0$, that would mean the $k$th digit is the first digit in the group. If
52+
$j=100$, that would mean the $k$th digit is the $99$-th digit in the group,
5353
etc. From there, we can divide $j$ by $n$ (the length of the numbers in the
54-
group), which gives us the position of the number that contains the $k$-th digit
54+
group), which gives us the position of the number that contains the $k$th digit
5555
within the group (also $0$-based). Similarly as before, a position of $0$ means
5656
that the number is the first number in the group, and a position of $100$ means
5757
that the number is the $99$-th number in the group.
5858

59-
To calculate the exact number the $k$-th digit is in, we can add the position of
59+
To calculate the exact number the $k$th digit is in, we can add the position of
6060
the number within the group (which we just found) to the value of the first
6161
number of the group, which is just $10^{n-1}$ (you can find this pattern from the
6262
beginning example). Now, all that's left is finding the position of the $k$-th
@@ -79,10 +79,10 @@ position that's $1$ plus a multiple of $3$, meaning its position modulo $3$
7979
equals $1$. Finally, the third digit in each number is always $2$ plus a
8080
multiple of $3$, meaning that its position modulo $3$ equals $2$. This pattern
8181
extends for numbers of all sizes, and it is thus why we can use the modulo
82-
operator to determine the $k$-th digit's $0$-based position within the number
82+
operator to determine the $k$th digit's $0$-based position within the number
8383
it's inside.
8484

85-
Now, we can calculate our answer by converting the number that the $k$-th digit
85+
Now, we can calculate our answer by converting the number that the $k$th digit
8686
is in into a string and indexing it at the position we've just found.
8787

8888
## Implementation
@@ -111,7 +111,7 @@ int main() {
111111
ll k;
112112
cin >> q;
113113

114-
for (int i = 0; i < q; i++) {
114+
for (int i = 0; i < q; i++) {
115115
cin >> k;
116116
/*
117117
* Subtract k by sizes of groups until k becomes smaller than the size

0 commit comments

Comments
 (0)