Number of non-negative solutions of the equation ax + by = c

Правка en1, от BumbleBee, 2018-10-22 20:03:19

I want to count the number of non-negative solutions of the equation: ax + by = c.

I know the naive approach where I can iterate over all non-negative y such that c - by is non-negative and count if c - by is divisible by a. Before starting iteration, I can check if c is a multiple of the greatest common divisor of a and b. If not, then I can simply return zero. But this will cost huge runtime for large values of a, b and c.

What is the most efficient solution for this?

Теги diofant equation, diophantine, gcd, extended euclid

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский BumbleBee 2018-10-22 20:03:19 562 Initial revision (published)