Editorial for SAC '22 Code Challenge 3 Junior P4 - Normal Conversions


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: maxcruickshanks

Subtask 1

This subtask was intended to reward solutions that used one of the built-in functions to convert from binary to decimal and vice-versa.

Time Complexity: \mathcal{O}(Q(\log_{b_1}(n_{10}) + \log_{b_2}(n_{10})))

Subtask 2

First, convert n to base-10, n_{10}, with built-in functions or manually (multiply each digit by its corresponding power: digit 1 by {b_1}^0, digit 2 by {b_1}^1, digits 3 by {b_1}^2, etc.).

Next, find the largest power of b_2 that you can remove from n_{10} and then place that in an array for each digit.

Repeat the above step until n_{10} is 0 and output the answer.

Time Complexity: \mathcal{O}(Q(\log_{b_1}(n_{10}) + \log_{b_2}(n_{10})))


Comments

There are no comments at the moment.