V
V
vladimir percov2017-03-31 14:39:34
Mathematics
vladimir percov, 2017-03-31 14:39:34

Find the maximum and minimum value from integer division?

Good day!
You are given three unknown integers x, y and z.
You know the integer division values ​​r = z / x and l = z / y.
What is the minimum and maximum possible division by integer y / x?
How to solve, tell me?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Mercury13, 2017-03-31
@Arhimed96

UPD. Rewrote from scratch.
r <= z/x < r + 1
l <= z/y < l + 1
Then y/x = z/x : z/y > r / (l+1)
On the other hand: y/x < z/ x : z/y < (r+1)/l
While I see the range [r / (l+1)]; [(r+1)/l]
The second is minus one if it's an exact integer: you can get closer, but you can't reach it. Simulate it like this…
[r / (l+1)]; [r/l]
Let's show that the bounds are reachable (for example, the first one). It touches on two inequalities.
z/x < r + 1
z/y >= l
By choosing x, y and z, we can bring the second to equality and approximate the first as much as we like.
UPD2. Let r = [z/x] = 10, l = [z/y] = 3
Then [y/x] will be between [10/4] = 2 and [10/3] = 3. parts - then from 2.5 to 3 2/3.
z=100.000, x=10.000, y=25.001, y/x=2.5001
z=100.000, x=9091, y=33.333, y/x ≈ 3.66659

T
TomasHuk, 2017-03-31
@TomasHuk

If I understood the question correctly, then r and l are also integers.
Therefore, y=z/l and x=z/r.
As a result, y/x=(z/l)/(z/r)=r/l.

M
Mark Nikitin, 2017-03-31
@MarkNikitin

Here you need, as for me, to use the minimax function, and then you can solve it in the matlab mathematical package

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question