Given a natural , a basis and a natural number , we want to write in basis using exactly characters, following the next format:
If in basis has exactly digits, you only must write in basis .
If in basis has less than digits, you must add hashes on the left.
If in basis has more of digits, you must write asterisks instead of .
Your task is to write a program that, given a sequence of triplets , , , prints for each one a line following this format.
The input is a sequence of triplets , , , with , and .
For each triplet of the input, print a line according to the described format.
Strings are not allowed in this problem.
We suggest you to use a function @number_of_digits(n, b)@ that, given two natural numbers |n| and |b| with , returns the number of digits that requires the representation of |n| in basis |b|.
You must use recursion to write in basis (without the hashes).
Author: Unknown
Translator: Carlos Molina
Generation: 2026-01-25T11:28:11.747Z
© Jutge.org, 2006–2026.
https://jutge.org