Once there was a pig, which was very fond of treasure hunting.The last treasure hunt he bring back a full packageof diamonds, which too delight tofall asleep for a few days. But there are t
Once there was a pig, which was very fond of treasure hunting. The last treasure hunt he bring back a full package of diamonds, which too delight to fall asleep for a few days. But there are too many diamonds, and it has new troubles. It wants to get some diamonds sold for cash to buy its girlfriend pretty things. The price of a diamond is proportional to its weight, the heavier the diamond, the greatest price it worth. So he wants to know the accurate weight of some diamonds going to sell. Poor it only has an old balance, and the balance has no scale. You can only see which side of the balance is heavier, or both side have the same weight. It has N weights with different kilogram, and there are Ci for each kinds of weight. To simplify the problem, the kilogram of all weight and all the diamonds are integer. M diamonds is planning to be sold, the diamond merchant told the pig the ith diamond weighs wi kg, you know, businesses may misrepresent the weight, and maybe the actual weight of this diamond is not wi kg and the merchant chart it. So the pig needs to know the exact weight of each diamond. That is to say, you can puts any weights you want and the diamond need to be measure on both side of the balance and know which side is heavier in this state. If you can figure out the exact weight of this diamond through the results, then you output an “Yes”, or you output an “No” means you can’t sure the exact weigh of this diamond. It finds you smart to tell the answer.