Model this as a weighted directed graph. If a / b = 2.0, create an edge from a to b with weight and a reverse edge from b to a with weight . Now answering a / c becomes a path-finding problem.
To compute x / y, search for a path from x to y in the graph. Multiply all edge weights along the path. If x connects to y through b, and the edges are and , the answer is . No path means the division is undefined, so return .