For a week and a half in small raids we have been thinking how to solve it. Maybe someone here can :)
Two arrays of natural numbers are given: x
and y
(both arrays are non-decreasing) and a positive integer Q
Find numbers from these arrays such that x[i] * y[j]
as close to Q
as possible.
The complexity should not exceed O(n+m)
, where n
and m
are the size of the arrays.