Magic Fraction

For Question check www.hackerearth.com
Make Path

Question included in the solution