Counting Mushrooms
문제
Andrew the mushroom expert is investigating mushrooms native to Singapore.
As part of his research, Andrew collected mushrooms labelled to . Each mushroom is of one of two species, which are called A and B.
Andrew knows that mushroom belongs to species A, but as the two species look the same, he does not know the species of mushrooms to .
Fortunately, Andrew has a machine in his lab that can help with this. To use this machine, one should place two or more mushrooms in a row inside the machine (in any order) and turn the machine on. Then, the machine calculates the number of adjacent pairs of mushrooms that are of different species. For example, if you place mushrooms of species (in that order) into the machine, the result will be .
However, as operating the machine is very expensive, the machine can be used for a limited number of times. In addition, the total number of mushrooms placed in the machine across all its uses cannot exceed . Use this machine to help Andrew count the number of mushrooms of species A collected.