The base-three answer in a form that doesn’t give anything away: 1111 (base three) = 3³+3²+3¹+3º = 40 (base ten).

It might be fun to work it out the hard way. You can obviously weigh 40 pounds by using all four pieces, whatever individual sizes they are. To weigh 39 pounds, one of the weights has to be one pound so you can take that one off the pan. That also makes it possible to weigh one pound (obviously) by using only that weight. And if you put the other three weights (39 pounds total) on one pan and the bale of hay plus the 1-pound weight on the other, it balances a bale that’s 38 pounds. So there’s four of your forty possible weights accounted for (1, 38, 39 and 40).

Next step is to take another stone away. If you assume another one-pound stone (nobody said the four pieces had to be four different sizes), that lets you weigh 38 pounds again (by setting the two one-pound stones aside), 37 (the remaining two stones on one pan and the bale plus one one-pounder on the other), and 36 (the remaining two stones vs the bale and both one-pound stones). It also allows you to weigh two pounds (the two smaller stones against just the bale). But now you’ve only accomplished a total of seven out of forty weights, and you’re running out of pieces, so it’s time to backtrack.

Forget about the second one-pound stone and try again with a two-pounder instead. This allows you to weigh 1 pound (1-pound stone vs bale), 2 (2-pound stone vs bale), 3 (1- and 2-pound stones vs bale), 34 (last two vs bale plus 1- and 2-pounds), 35 (last two vs bale plus 2), 36 (last two vs bale plus 1), 37 (last two vs bale alone), 38, 39 and 40 (as described in the second paragraph). Ten out of forty. You can also get 36 by weighing the last two stones plus the 1-pounder against the bale and the 2-pounder; there’s something about having more than one way to measure the same weight that seems to waste combinations. A two-pounder isn’t going to hack it.

So make the second stone three pounds. Fiddling for a while, this allows you to measure 1, 2, 3, 4, 32, 33, 34, 35, 36, 37, 38, 39 and 40. That’s thirteen out of forty, so record that much information and move on to try weights for the last two stones. You know their combined weight is 36 pounds, so if you pick a weight for one you know what the weight is for the other. And you know that it won’t help you to make either of them three pounds or less; in fact you can pretty much bet that they’ll both be over four pounds because you’ve got that combination covered with the first two. So try four pounds for the third, five pounds, etc, knowing that you’ll know one way or another by the time you get to eighteen (at which point the “fourth” stone becomes smaller and you just end up running through the same combinations with the third and fourth stones reversed).