0

(Second time I ask this because the previous was not very clear so I deleted it) Hi, I've trying to solve this problem (competitive programming) called Divide a days ago, it's states:

Given $p,q,n \le 10^{10}$, find all the tuples such that:

$\frac {ab} {a+b} = c $

($a+b|ab$, $a \in [1;p]$, $b\in [1;q]$, $c\in [1;n]$, all integers)

Note: this is not about to check whether $ab$ is divisible by $a+b$ but to find how many valid tuples (a,b) when put into that expression above, results results in a number $c\le n$

As the values $p,q,n$ are too big and cannot be calculated by brute-force, is there a way to calculate how much of such tuples exists in $O(1)$?

Original problem: https://dmoj.uclv.edu.cu/problem/2023orcop1112b

What I've reached by myself:

  1. When $a=b$ then $\frac a 2 \le n$ and $a \le 2n$ , so that gives some tuples of the form $(2k, 2k)$

  2. When $a=kb$ then $\frac {kb} {k+1}$ as $k$ and $k+1$ are coprime, must find a $k+1$ that divides $b$, (can be easily calculated)

Nothing more useful :/

H3LL
  • 11
  • 1
  • Can you credit the source where you encountered this problem? 2. What approaches have you already considered? What is the best algorithm you have found so far? 3. Is $c$ given as part of the input?
  • – D.W. Sep 10 '23 at 04:00
  • Please don't duplicate your prior question. The characterization of solutions in the linked dupes there (and now here) easily leads to algorithms to enumerate solutions. – Bill Dubuque Sep 10 '23 at 05:45