p/2$, $h(a) > p/2$; thus $h(x) = p/2$ has exactly one solution $x \in [a/2,a]$ if and only if there is $x_0 \in [a/2,a]$ with $h'(x_0) = 0$ and $h(x_0) = p/2$. The first condition implies $x_0 = \sqrt{ab/2}$, and then the second condition gives $8ab = p^2$. Note that $\sqrt{ab/2}$ is in $[a/2,a]$ since $a>b$ and $a**b>c$ are integers and $a \leq 9$. Indeed, the only integers $(a,b)$ such that $2 \leq b < a \leq 9$ and $8ab$ is a perfect square are $(a,b) = (4,2)$, $(6,3)$, $(8,4)$, $(9,2)$, and $(9,8)$, and the first four possibilities do not produce triangles since they do not satisfy $a<2b$. This gives the claimed result.
\item[B6]
\textbf{First solution.}
The desired count is $\frac{2016!}{1953!}- 63! \cdot 2016$, which we compute using the principle of inclusion-exclusion.
As in A2, we use the fact that 2017 is prime; this means that we can do linear algebra over the field $\mathbb{F}_{2017}$. In particular, every nonzero homogeneous linear equation in $n$ variables over $\mathbb{F}_{2017}$ has exactly $2017^{n-1}$ solutions.
For $\pi$ a partition of $\{0,\dots,63\}$,
let $|\pi|$ denote the number of distinct parts of $\pi$,
Let $\pi_0$ denote the partition of $\{0,\dots,63\}$ into 64 singleton parts.
Let $\pi_1$ denote the partition of $\{0,\dots,63\}$ into one 64-element part.
For $\pi, \sigma$ two partitions of $\{0,\dots,63\}$, write $\pi | \sigma$ if $\pi$ is a refinement of $\sigma$
(that is, every part in $\sigma$ is a union of parts in $\pi$). By induction on $|\pi|$, we may construct
a collection of integers $\mu_\pi$, one for each $\pi$, with the properties that
\[
\sum_{\pi | \sigma} \mu_\pi = \begin{cases} 1 & \sigma = \pi_0 \\ 0 & \sigma \neq \pi_0 \end{cases}.
\]
Define the sequence $c_0, \dots, c_{63}$ by setting $c_0 = 1$ and $c_i = i$ for $i>1$.
Let $N_\pi$ be the number of ordered 64-tuples $(x_0,\dots,x_{63})$ of elements of $\mathbb{F}_{2017}$
such that $x_i = x_j$ whenever $i$ and $j$ belong to the same part and
$\sum_{i=0}^{63} c_i x_i$ is divisible by 2017. Then $N_\pi$ equals $2017^{|\pi|-1}$
unless for each part $S$ of $\pi$, the sum $\sum_{i \in S} c_i$ vanishes; in that case,
$N_\pi$ instead equals $2017^{|\pi|}$.
Since $c_0, \dots, c_{63}$ are positive integers which sum to $1 + \frac{63 \cdot 64}{2} = 2017$, the second outcome only occurs for $\pi = \pi_1$. By inclusion-exclusion, the desired count may be written as
\[
\sum_{\pi} \mu_\pi N_\pi = 2016 \cdot \mu_{\pi_1} + \sum_{\pi} \mu_\pi 2017^{|\pi|-1}.
\]
Similarly, the number of ordered 64-tuples with no repeated elements may be written as
\[
64! \binom{2017}{64} = \sum_{\pi} \mu_\pi 2017^{|\pi|}.
\]
The desired quantity may thus be written as $\frac{2016!}{1953!} + 2016 \mu_{\pi_1}$.
It remains to compute $\mu_{\pi_1}$. We adopt an approach suggested by David Savitt: apply inclusion-exclusion
to count distinct 64-tuples in an \emph{arbitrary} set $A$. As above, this yields
\[
|A|(|A|-1) \cdots (|A|-63) = \sum_{\pi} \mu_\pi |A|^{|\pi|}.
\]
Viewing both sides as polynomials in $|A|$ and comparing coefficients in degree 1 yields
$\mu_\pi = -63!$ and thus the claimed answer.
\noindent
\textbf{Second solution.}
(from Art of Problem Solving, user \texttt{ABCDE})
We first prove an auxiliary result.
\begin{lemma*}
Fix a prime $p$ and define the function $f(k)$ on positive integers by the conditions
\begin{align*}
f(1,p) &= 0 \\
f(k,p) &= \frac{(p-1)!}{(p-k)!} - kf(k-1,p) \qquad (k>1).
\end{align*}
Then for any positive integers $a_1,\dots,a_k$ with
$a_1 + \cdots + a_k < p$, there are exactly $f(p)$ solutions to the equation $a_1 x_1 + \cdots + a_k x_k = 0$
with $x_1,\dots,x_k \in \mathbb{F}_p$ nonzero and pairwise distinct.
\end{lemma*}
\begin{proof}
We check the claim by induction, with the base case $k=1$ being obvious.
For the induction step, assume the claim for $k-1$.
Let $S$ be the set of $k$-tuples of distinct elements of $\mathbb{F}_p$;
it consists of $\frac{p!}{(p-k)!}$ elements.
This set is stable under the action of $i \in \mathbb{F}_p$ by translation:
\[
(x_1,\dots,x_k) \mapsto (x_1 + i, \dots, x_k + i).
\]
Since $0 < a_1 \cdots + a_k < p$, exactly one element of each orbit gives a solution of
$a_1 x_1 + \cdots + a_k x_k = 0$. Each of these solutions contributes to $f(k)$ except
for those in which $x_i = 0$ for some $i$.
Since then $x_j \neq 0$ for all $j \neq i$, we may apply the induction hypothesis to see that there are
$f(k-1,p)$ solutions that arise this way for a given $i$ (and these do not overlap).
This proves the claim.
\end{proof}
To compute $f(k,p)$ explicitly, it is convenient to work with the auxiliary function
\[
g(k,p) = \frac{p f(k,p)}{k!};
\]
by the lemma, this satisfies $g(1,p) = 0$ and
\begin{align*}
g(k,p) &= \binom{p}{k} - g(k-1,p) \\
&= \binom{p-1}{k} + \binom{p-1}{k-1} - g(k-1, p) \qquad (k>1).
\end{align*}
By induction on $k$, we deduce that
\begin{align*}
g(k,p) - \binom{p-1}{k} &= (-1)^{k-1} \left( g(1,p) - \binom{p-1}{1} \right) \\
&= (-1)^k (p-1)
\end{align*}
and hence
$g(k,p) = \binom{p-1}{k} + (-1)^k (p-1)$.
We now set $p=2017$ and count the tuples in question.
Define $c_0,\dots,c_{63}$ as in the first solution. Since $c_0 + \cdots + c_{63} = p$,
the translation action of $\mathbb{F}_p$ preserves the set of tuples; we may thus assume without loss of generality
that $x_0 = 0$ and multiply the count by $p$ at the end. That is, the desired answer is
\begin{align*}
2017 f(63, 2017) &= 63! g(63, 2017) \\
& = 63! \left( \binom{2016}{63} - 2016 \right)
\end{align*}
as claimed.
\end{itemize}
\end{document}
**