title: Finding the closest integer fraction to a given random real between 0..1, given ranges of numerator and denominator
body: <p>Given two ranges of positive integers <code>x: [1 ... n]</code> and <code>y: [1 ... m]</code> and random real R from 0 to 1, I need to find the pair of elements (i,j) from x and y such that x_i / y_j is closest to R.</p>
  
  <p>What is the most efficient way to find this pair?</p>