Count the number of non-negative integers $(x;y;z;t)$ of $ax+by+cz+dt = n$

51 Views Asked by At

Problems: Find an efficient algorithm counting the number of non-negative integers $(x;y;z;t)$ of $ax+by+cz+dt = n(a, b, c, d, n \geq 1)$

If $n$ is not too large, use dynamic program on n is ok. But if $n\approx10^{10000}$, and even if $a, b, c, d, \leq$, it wil take so much time to run.

Some simpler cases
If $ax+by = n$, then the answer is $\Big\lfloor\frac{n}{ab}\Big\rfloor + x\,\,\, (x=0/1)$
If $ax+by+cz = n$, read here $ax+by+cz = n$

From the link , I have an approach to the problem:
If $n$ is not divided by $\gcd(a,b,c,d)$, then, there is no non-negative integer solution
Otherwise, we divide 2 sides with $\gcd(a,b,c,d)$. So WLOG, $\gcd(a,b,c,d) = 1$.

The number of solutions is the coefficient of $x^n$ in expansion $[x^0+x^a+(x^a)^2+...][x^0+x^b+(x^b)^2+...][x^0+x^c+(x^c)^2+...][x^0+x^d+(x^d)^2+...] = ANS$
$=\frac{1}{(1-x^a)(1-x^b)(1-x^c)(1-x^d)}$ (Taylor's Series)

$ζ_m$ denotes $e^\frac{2πi}{m}$
$ANS = (1-x)^4 \prod\limits_{k=1}^{a-1}(1-ζ_a^{-k}x)(1-ζ_b^{-k}x)(1-ζ_c^{-k}x)(1-ζ_d^{-k}x)$

I still stuck here. Is there an general formula to this problem or an efficient algorithm can run quite fast if $a, b, c, d \leq 5$ ?

P/s: Sorry for my bad English.