This base conversion algorithm has an application in this problem 1811E - Living Sequence.Why does the base conversion work here.What do the remainders signify in the base conversion?
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
This base conversion algorithm has an application in this problem 1811E - Living Sequence.Why does the base conversion work here.What do the remainders signify in the base conversion?
Name |
---|
you can think of it like just converting to base 9 (because there are 9 digits) but with different namings/symbols.
In base 10, you can decompose numbers by their decimal cases, for example
Unable to parse markup [type=CF_MATHJAX]
. The same goes for an arbitrary baseUnable to parse markup [type=CF_MATHJAX]
.Let $$$n$$$ be a number in base $$$B$$$ with digits
Unable to parse markup [type=CF_MATHJAX]
. Following the same logic as of base $$$10$$$, $$$n$$$ can be written asUnable to parse markup [type=CF_MATHJAX]
. Now, notice that, all digits have "values" divisible by $$$B$$$, except for digit $$$0$$$. So, we can write $$$n$$$ in the follow wayUnable to parse markup [type=CF_MATHJAX]
. By Euclid's division lemma, the quotient of the division of $$$n$$$ by $$$B$$$ isUnable to parse markup [type=CF_MATHJAX]
, and the remainder is $$$d_0$$$. Observe that the quotient of that division is the base $$$B$$$ numberUnable to parse markup [type=CF_MATHJAX]
, which is our original number $$$n$$$, without it's last digit. Therefore, we can repeat this procedure until we find all the digits of $$$n$$$.In the problem you mentioned, you're basically counting in base $$$9$$$, except we are using the digits
Unable to parse markup [type=CF_MATHJAX]
instead of $$$0$$$ to $$$8$$$. So, all you need to do is find the base $$$9$$$ number, and map the digitsUnable to parse markup [type=CF_MATHJAX]
toUnable to parse markup [type=CF_MATHJAX]
.Thank you for the base conversion explanation.
op explanation