Solution:
We will prove that the minimum number of measurements equals 2. Denote the weights of a genuine and a counterfeit coin by x and y respectively, and let ai=1 if the coins in the i-th wagon are counterfeit, and ai=0 otherwise.
In the first measurement, take one coin from each wagon. Then a1+a2+⋯+an=x−ynx−m1, where m1 is the obtained mass. We assume that m1=nx, since otherwise there are no counterfeit coins.
In the second measurement, for some q∈N, we take qi−1 coins from the i-th wagon. If the obtained mass is m2, we have a1+qa2+⋯+qn−1an=x−y(1+q+⋯+qn−1)x−m2. From here we obtain
f(a1,a2,…,an)=a1+a2+⋯+ana1+qa2+⋯+qn−1an=nx−m1(1+q+⋯+qn−1)x−m2
We want the value of f to uniquely determine a1,…,an. Thus, it suffices to show that there exists a natural number q such that the function f:{0,1}n∖{(0,0,…,0)}→R is injective.
For fixed a=(a1,a2,…,an) and b=(b1,b2,…,bn), the equality f(a)=f(b) is equivalent to Pa,b(q)=(abn−ban)qn−1+⋯+(ab2−ba2)q+(ab1−ba1)=0, where a=a1+a2+…+an=0=b=b1+b2+…+bn. Therefore, if the function f is not injective, then q is a root of the polynomial
P(q)=a,b∏Pa,b(q)
Since none of the polynomials Pa,b is identically equal to 0, there are only finitely many numbers q for which P(q)=0, so it is possible to choose q for which f is an injective function.
In this way, in two measurements we can determine a1,…,an, i.e., the wagons with counterfeit coins. Finally, we determine y from the equality y=x−a1+a2+⋯+annx−m1.
On the other hand, one measurement is not sufficient, because by taking ki coins from the i-th wagon we obtain the equation k1a1+⋯+knan=x−ykx−m (where k=k1+⋯+kn) which in general has multiple solutions. For example, two possible solutions for (a1,a2,…,an,y) are (1,0,…,0,x−k1kx−m) and (0,0,…,1,x−knkx−m).