Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

The Lion Queen

By RHaque · Limits 1s, 512 MB

A lioness is trying to hunt down a buffalo. The lioness spots a buffalo aa metres away. As soon as she sees the buffalo, the buffalo spots her as well, and starts running. The lioness immediately starts chasing after her. If the lioness is bb times faster than the buffalo, how far will she have to run before she can capture the buffalo?


The input consists of two integer numbers, denoting the values of aa and bb respectively, as described above.


2a,b1042 \leq a,b \leq 10^4


It can be proven that the distance which the lioness will have to run is a rational number, that is it can be written in the form of a fraction p/qp/q. Output two space-separated integers pp and qq, so that p/qp/q is the answer to this problem. You must output the fraction in its fully reduced form, (e.g. if the answer to the problem is 8/48/4, you must output 22 and 11 since 2/12/1 is the reduced form of 8/48/4).


4506 85
63835 14



    77% Solution Ratio

    TanbeerEarliest, 2w ago

    Being_GoromFastest, 0.0s

    nav99X_EWULightest, 0 B

    pathanShortest, 83B


    Login to submit