I just got 10227 (Forests) Accepted using C++
![:(](./images/smilies/icon_frown.gif)
Anyway here's the algorithm to solve False coin problem (665)
Define 2 sets, lets say, Less and More holding the possible coins which are fake.
At first Less := [1..n] and More := [1..n]
Then, read the 2 sets of coins contained in the 2 pans. Store them in 2 separate sets, namely Left and Right.
If the weight of both pans are equal then the coins are definitely not fake.. meaning that we can eliminate those coins from our previous sets Less and More
Less := Less - Left - Right
More := More - Left - Right
If the left pan weighs less, that means that the fake coin is either on the left pan or the right pan, which leads to:
Less := Less * Left
More := More * Right
If the left pan weighs more, that means the false coin is either on the left or the right pan, which leads this time to:
Less := Less * Right
More := More * Left
Finally, the false coin can be found by Remaining := Less + More, where Remaining is another set
If the number of elements in Remaining[] is only 1 then this is the false coin.
* means intersection, + means union and minus (-) means difference of the 2 sets.
Hope that helps..