Let $m \in\mathbb N, m > 2$ and $S_m = \{0, 1,4\pmod{m},...,(m-1)^2 \pmod{m}\}.$
We are given a function $f_m(x) = 9x^2 + 18ax + 9a^2 - b \pmod{m}$ where $a, b \in\mathbb N$.
Can we find every $x \in\mathbb N$ such that $f_m(x) \in S_m$ efficiently for large $m$?
If not, can we get a number of these valid $x$ somehow?
I know two ways of accomplishing this, but these are both inefficient for large $m$:
Compute and store $S_m$ and then search for $f_m(1), f_m(2), ... , f_m(m)$ one by one.
It's fast enough, but storing $S_m$ becomes a problem if $m$ is quite a large number.For each $x = 1, 2, ... m$ iterate over $S_m$ and test if $f_m(x) = s_j \in S_m$ for some $j$.
We avoid storing $S_m$ here but this is not that fast since we need to iterate $m$ times.