Use the cyclic logarithmic coloring
Here the floor function places in the unique half-open real interval . If , then
because . For any real and , is either or . Applying this to the logarithms of and shows that their bin indices differ by or , and hence have different residues in modular arithmetic modulo . This proves the required separation, including both endpoints of the prescribed ratio interval. The half-open bins remove any ambiguity at their boundaries.
Let the known phase gate on the answer register be
where the comparison uses ordinary integers, not modular arithmetic. A reversible circuit computes the predicate, applies a Pauli Z gate to its flag, then performs uncomputation.
The compute-phase-uncompute construction now gives
Use modular-oracle inversion by negation to realize the last operation with one further query. Exactly two oracle queries implement , returning the answer register and comparison workspace to their initial states.