Solution (source code)

= Solution

Let $\ell_j$ be the Lagrange <basis> <polynomials> for the nodes. Necessity and existence give uniquely $A_j=\int_{-1}^1\ell_j(t)dt$, because every <polynomial> of degree at most $n-1$ is $\sum_jp(t_j)\ell_j(t)$.