Example 4 In a cyclic quadrilateral $ABCD$, the lengths of the four sides $AB, BC, CD, DA$ are all positive integers, $DA=2005, \angle ABC=\angle ADC=90^{\circ}$, and $\max \{AB, BC, CD\}<2005$. Find the maximum and minimum values of the perimeter of quadrilateral $ABCD$. (2005 China National Training Team Test Question)
Let $A B=a, B C=b, C D=c$, then $a^{2}+b^{2}=A C^{2}=c^{2}+2005^{2}$, so $2005^{2}-a^{2}=b^{2}-c^{2}=(b+c)(b-c)$, where $a, b, c \in\{1,2, \cdots, 2004\}$.

Assume $a \geqslant b$, first fix $a$, let $a_{1}=2005-a$, then
$$(b+c)(b-c)=2005^{2}-a^{2}=a_{1}\left(4010-a_{1}\right)$$

From $a^{2}+b^{2}>2005^{2}$, we get $a>\frac{2005}{\sqrt{2}}>1411$, so $1 \leqslant a_{1}\sqrt{(b+c)(b-c)}=\sqrt{a_{1}\left(4010-a_{1}\right)}$.
When $a_{1}=1$, $a=2004,(b+c)(b-c)=4009=19 \times 211$, so, $b+c \geqslant 211, a+b+c \geqslant 2004+211=2215>2155$;

When $a_{1}=2$, $a=2003,(b+c)(b-c)=2^{4} \times 3 \times 167$, and $b+c$ and $b-c$ have the same parity, so, $b+c \geqslant 2 \times 167, a+b+c \geqslant 2003+2 \times 167>2155$;

When $a_{1}=3$, $a=2002,(b+c)(b-c)=3 \times 4007$, so, $b+c \geqslant 4007$, $a+b+c \geqslant 2002+4007>2155$;

When $a_{1}=4$, $a=2003,(b+c)(b-c)=2^{3} \times 2003$, so, $b+c \geqslant 2 \times$ $2003, a+b+c \geqslant 2001+2 \times 2003>2155$;

When $a_{1}=5$, $a=2000,(b+c)(b-c)=3^{2} \times 5^{2} \times 89$, so, $b+c \geqslant 225$, $a+b+c \geqslant 2000+225>2155$;

When $a_{1}=6$, $a=1999,(b+c)(b-c)=6 \times 4004=156 \times 154$, so, $b+c \geqslant 156, a+b+c \geqslant 1999+156=2155$;

When $a_{1} \geqslant 7$, because $b+c>\sqrt{a_{1}\left(4010-a_{1}\right)}$, so $a+b+c>$ $\sqrt{a_{1}\left(4010-a_{1}\right)}+2005-a_{1}$, but $7 \leqslant a_{1}2155$.

Actually, $\sqrt{a_{1}\left(4010-a_{1}\right)}+2005-a_{1}>2155 \Leftrightarrow \sqrt{a_{1}\left(4010-a_{1}\right)}>$ $150+a_{1} \Leftrightarrow-a_{1}^{2}+4010 a_{1}>a_{1}^{2}+300 a_{1}+150^{2} \Leftrightarrow a_{1}^{2}-1855 a_{1}+11250<0$, by the properties of quadratic functions, this inequality holds when $7 \leqslant a_{1}<594$.

In summary, we always have $a+b+c \geqslant 2155$, thus $A B+B C+C D+D A \geqslant 2155+$ $2005=4160$

When $A B=1999, B C=155, C D=1$, the equality holds, so the minimum perimeter of quadrilateral $A B C D$ is 4160.

Next, we find the maximum perimeter of quadrilateral $A B C D$:
Since $a \geqslant b, c<2005$, so $b+c<a+2005=4010-a_{1}$, so from (1) we know $a_{1}<b-c<b+c<4010-a_{1}$.

Since $a_{1}$ and $b-c$ have the same parity, so $b-c \geqslant a_{1}+2$, thus
$$b+c=\frac{a_{1}\left(4010-a_{1}\right)}{b-c} \leqslant \frac{a_{1}\left(4010-a_{1}\right)}{a_{1}+2}$$

When $b-c=a_{1}+2$,
$$a+b+c=2005-a_{1}+\frac{a_{1}\left(4010-a_{1}\right)}{a_{1}+2}=6021-2\left(a_{1}+2+\frac{4012}{a_{1}+2}\right)$$

And $4012=2^{2} \times 17 \times 59=68 \times 59$, so $a+b+c \leqslant 6021-2 \cdot(68+59)=5767$.
When $b-c \neq a_{1}+2$, $b-c \geqslant a_{1}+4$, thus
$$a+b+c \leqslant 2005-a_{1}+\frac{a_{1}\left(4010-a_{1}\right)}{a_{1}+4}$$

And $2005-a_{1}+\frac{a_{1}\left(4010-a_{1}\right)}{a_{1}+4} \leqslant 5767 \Leftrightarrow a_{1}^{2}-122 a_{1}+7524 \geqslant 0$.
Notice that $\Delta=122^{2}-4 \times 7524<0$, so the above inequality always holds.
Therefore, $A B+B C+C D+D A \leqslant 5767+2005=7772$, when $a=1948, b=$ $1939, c=1880$, the equality holds, hence the maximum perimeter of quadrilateral $A B C D$ is 7772.