Question: Description: Victor wrote a number nnn in base bbb on the whiteboard. He then converts every digit of nnn into base 10 and erases the

Description: Victor wrote a number nnn in base bbb on the whiteboard. He then converts every digit of nnn into base 10 and erases the original number: For example, BB529D in base 16 would become 11 11 5 2 9 13. However, this time, he forgot to add spaces in between to distinguish the digits, and now he has forgotten the original number. He now wonders how many possible values of nnn could have been the original number. Given the converted number as a string (sss) and the base (bbb), find out how many numbers could have been the original number, modulo 109+710^9+7109+7. Explanation: B -> 11 B -> 11 5 -> 5 2 -> 2 9 -> 9 D -> 13 BD925B -> 111152913 Some other numbers in base 16 that become 111152913 are: 111152913, B1152913, and B1F529D. Constraints: 1s1051 \leq |s| \leq 10^51s105 1b1091 \leq b \leq 10^91b109 Examples solve("111152913", 16) -> 16 solve("1111", 200) -> 7 solve("52319", 619) -> 13

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!