This problem belongs to comparing quantities.
as we have two different units cm and km .so we need to convert any one of the units to same unit.i am converting km to cm here .
1km=1000m
100cm=1m
so 1000m=100000 cm
so 5km=5000m=500000 cm
1cm:500000 cm =1/500000 is the ratio to fraction form.As we having same units on both numerator and denominator it will cancels.