Separating in lines P93424


Statement
 

pdf   zip

thehtml

Given a natural number n, a base b, and a natural number q, print n in base b, but placing the digits of n in groups of q at every line.

Input

Input consists of several cases, each with n > 0, 2 ≤ b ≤ 10, and q > 0.

Output

For every case, print n in base b, but placing q digits at every line. If the number of digits of ‍n in base b is not a multiple of q, the first line must be the shortest. Print a line with 10 ‍dashes at the end of every case.

Observation

You should not use vectors or alike to solve this problem.

Public test cases
  • Input

    12345 10 3
    123456 10 3
    1234567 10 3
    12 10 3
    14 2 1
    1000000000 2 10
    

    Output

    12
    345
    ----------
    123
    456
    ----------
    1
    234
    567
    ----------
    12
    ----------
    1
    1
    1
    0
    ----------
    1110111001
    1010110010
    1000000000
    ----------
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++