Hide

Problem F
Treating Fractions Irrationally

Anna has a big report to write concerning the voting habits of left-handed Democrats who own one or more kitchen blenders. She has a lot of statistics to report. For example, did you know that $56$ out of every $87$ left-handed Democrats who own one or more kitchen blenders can not name any of the current Supreme Court justices (yes, we were a bit shocked by this too.)

Now Anna is a bit irrational when it comes to fractions. She hates writing them as “$56/87$” but prefers the floating point version “$0.64367816091954022\ldots $

But this presents two problems. The first is that for most fractions, the floating point version will have to be truncated at some point. And this leads to the second problem: this truncated version is never equal to the original fraction. To minimize this second problem, Anna has decided that she will print the floating point version up to (but not including) the first $0$ or $9$ encountered, rounding down or up appropriately. So the above fraction would be written as “$0.64367816$”, while the fraction $55/87$ (which is equal to $0.6321839080459\ldots $) would be written as “$0.632184$”. If the very first digit after the decimal point is $0$ (as with the fraction $1/87$) then Anna just writes “$0$”; if the first digit after the decimal point is $9$ (as with the fraction $86/87$) then Anna just writes “$1$”. Finally if a $0$ or $9$ never appears in the floating point version (as with the fraction $58/87$) then Anna just throws out that data (so the world will never know, for example, that $58$ out of every $87$ left-handed Democrats who own one or more kitchen blenders make great fruit smoothies).

Input

Input consists of a single line containing two positive integers $n$ $d$, where $n < d \leq 100\, 000$.

Output

Display Anna’s truncated version of the fraction $n/d$. If the floating point version of $n/d$ does not contain a $0$ or $9$, display the phrase throw out.

Sample Input 1 Sample Output 1
56 87
0.64367816
Sample Input 2 Sample Output 2
55 87
0.632184
Sample Input 3 Sample Output 3
58 87
throw out
Sample Input 4 Sample Output 4
1 87
0

Please log in to submit a solution to this problem

Log in