Dividing the Digits of an Integer in Base k
InterviewTime limit1sMemory limit512 MB
Convert n to base k, split its digits at each 0, and print the sum of the distinct nonempty pieces in base k.
- Level
Easy3 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
You are given positive integers and . Let be written in base . Split each digit of at the digit 0, and let be the set of the resulting numbers. A piece that is empty because of consecutive zeros is not included in . Print the sum of the numbers in in base . For example, if and , then , contains 1 and 11, and , so the output is 1100.
Input
The first line contains the positive integers and , separated by a space.
Output
On the first line, print the sum of the numbers in written in base .
Constraints
,