Problem J
Raising the Bar
Yraglac sells the finest swords in the land, which he
fine-tunes to exact measurements. He engraves each sword’s
exact measurements in fractions of a metre so that his
customers know exactly what they’re getting. For example, his
builds his most famous dagger to exactly one third of a meter
in length so he engraves “
His customers find the fractions a little hard to work with
though and have requested that Yraglac adds the decimal
expansion for each fraction. Since some fractions have infinite
expansions, like how
Engraving takes time, so Yraglac wants to know exactly how many digits he’ll need to write after the decimal point as part of the finite sequence, and how many digits to write as part of the infinitely repeating sequence underneath a bar. Can you help out Yraglac?
Input
Input consists of two integers
Output
Output two space-separated integers
Sample Input 1 | Sample Output 1 |
---|---|
1 3 |
0 1 |
Sample Input 2 | Sample Output 2 |
---|---|
5 14 |
1 6 |
Sample Input 3 | Sample Output 3 |
---|---|
1 2 |
1 0 |
Footnotes
- Yraglac knows that he can write finite
decimal expansions as infinite expansions, since for example
, but he would rather write the finite expansion in these cases since it takes less engraving.