Why x * i / j is not equal to x / j * i ?

Revision en2, by dreamoon_love_AA, 2019-05-13 15:50:44

Hi, all.

I found a magic thing that $x\ /\ i * j$ is not always equal to $x * j\ /\ i$! For example, when $x = 12, i = 9, j = 6$, then $x\ /\ i * j = 6$ but $x * j\ /\ i = 8$. The fact surprised me.

Now, given three positive number $x$, $a$, $b$, I wonder how may pair of $(i,j)$ satisfy $x\ /\ i * j = x * j\ /\ i$ and $1 \le i \le a$ and $1 \le j \le b$?

I hope I can solve about $20$ tests which satisfy $1 \le x,a,b \le 10^9$ in 1 second. Can you help me?

PS. This is a problem that I give in some local contest. I feel it's interesting and share it here.

PS2. I think it's a math problem instead of programing problem.

History

Revisions

Rev. Lang. By When Δ Comment
en2 dreamoon_love_AA 2019-05-13 15:50:44 179 (published)
en1 dreamoon_love_AA 2019-05-13 15:44:39 508 Initial revision (saved to drafts)