Number of solutions of a diophantine equation using the rounding function With the equation defined as: 
$$\left\lfloor \frac {(x-1)(a_n-a_1)}{n-1}\right\rceil+\left\lfloor \frac {(y-1)(a_n-a_1)}{n-1}\right\rceil=N$$ 
How many integer values can $x$ and $y$ take as a $f(a_n,a_1,n,N)$ if $1\le x,y \le n$?


I have tried putting the equation into graphing software, but the graph was rather unaccurate (I hand checked an answer and it did not appear on the graph). The graph does look like a staircase with the length of the steps regular, maybe I was thinking that the $f(a_n,a_1,n,N)$ could have something to do with the number of steps within the square of boundary $1$ and $n$?


I have little to no knowledge of Diophantine equations, much less with the rounding function involved. I am not looking for a method of solving the equation, just a function that counts the number of solutions. Any help would be appreciated. 



EDIT
My previous question was answered very satisfactorily, but I was wondering if the same method provided by Arthur could still be used if the equation in turn was: $$\left\lfloor x(\ln(x\ln x))\right\rceil+\left\lfloor y(\ln(y\ln y))\right\rceil=N$$ 
Furthermore, as a greater challenge, is the method still valid for a more general equation: $$\sum _{i=1}^m \lfloor f(x_i) \rceil =N$$

Let $L = \lfloor \frac{(x-1)(a_n-a_1)}{n-1} \rceil$ and 
$R = \lfloor \frac{(y-1)(a_n-a_1)}{n-1} \rceil$ so that $L+R = N$
For $L = \lfloor z \rceil$ , $L-\frac{1}{2} \le z \lt L+\frac{1}{2}$ where $L \ge 0$. Rounding toward the nearest integer and $\frac{1}{2} \rightarrow 1$.
$$L-\frac{1}{2} \le  \frac{(x-1)(a_n-a_1)}{n-1}  \lt L+\frac{1}{2} $$
$$\frac{(L-\frac{1}{2})(n-1)}{a_n-a_1} +1 \le x \lt \frac{(L+\frac{1}{2})(n-1)}{a_n-a_1} + 1$$
$$\left\lceil\frac{(L-\frac{1}{2})(n-1)}{a_n-a_1}+1\right\rceil \le x \lt \left\lceil\frac{(L+\frac{1}{2})(n-1)}{a_n-a_1}+1\right\rceil$$
The lhs could be a negative fraction so include the $1$ in the floor.
Must limit $x$ s.t. $1 \le x \lt n+1$. The rhs could exceed the maximum, $n+1$. The lhs could exceed the maximum and the minimum $1$.
$$min\left(max\left(\left\lceil\frac{(L-\frac{1}{2})(n-1)}{a_n-a_1}+1\right\rceil ,1\right),n\right) \le x \lt min\left(\left\lceil\frac{(L+\frac{1}{2})(n-1)}{a_n-a_1}+1\right\rceil,n+1\right)\ \ \ (1)$$
Let $f_x(a_n,a_1,n,L)$ be the number of $x$ integers that satisfy equation ($1$).
$$f_x(a_n,a_1,n,L) = min\left(\left\lceil\frac{(L+\frac{1}{2})(n-1)}{a_n-a_1}+1\right\rceil ,n+1\right) - min\left(max\left(\left\lceil\frac{(L-\frac{1}{2})(n-1)}{a_n-a_1}+1\right\rceil,1\right),n\right)$$
Similarly let $f_y(a_n,a_1,n,R)$ be the number of $y$ integers
$$f_y(a_n,a_1,n,R) = min\left(\left\lceil\frac{(R+\frac{1}{2})(n-1)}{a_n-a_1}+1\right\rceil,n+1\right) - min\left(max\left(\left\lceil\frac{(R-\frac{1}{2})(n-1)}{a_n-a_1}+1\right\rceil,1\right),n\right)$$
$f_x(a_n,a_1,n,L)$ and $f_y(a_n,a_1,n,R)$ are identical.
Let $f(a_n,a_1,n,N)$ be the number of points $(x,y)$ such that the objective equation is satisfied.
$f(a_n,a_1,n,N) = \displaystyle \sum_{k=0}^{N}f_x(a_n,a_1,n,k)f_y(a_n,a_1,n,N-k)$
