Replace 2013 by a general odd number 2k−1, k≥2. The sum S=1+2+⋯+(2k−1) equals k(2k−1). For part a), the only number that can be determined with certainty is k, the one in the middle. To find k, ignore a card with an unknown number x on it, thus forming a set of 2k−2 cards, and ask about their average. It is an integer if and only if 2k−2 divides S−x=k(2k−1)−x=k(2k−2)+(k−x), i.e. if and only if 2k−2 divides k−x. Now 1≤x≤2k−1 gives ∣k−x∣≤k−1<2k−2 (by k≥2), thus x=k is the only possibility. Hence applying the procedure to each card will exhibit k.
Conversely, suppose that the card with a number m can be determined with certainty by asking a sequence of questions. Imagine that the number j on each card is replaced by 2k−j; the numbers 1,2,…,2k−1 are written on the cards again. Now ask the same sequence of questions. Since the average of 2k−j,…,2k−j is integer if and only if the average of j1,…,jn is, the answers will be the same as with the initial situation. Hence the questions that initially find the card with m will find the card with 2k−m in the new situation; so 2k−m=m and m=k. This completes a).
b) Let the cards be divided into groups so that the contents of each group as a whole is known. Since k is the unique number that can be found with certainty, all groups contain at least 2 cards each except possibly one, which contains the card with k and has size 1. It follows that the number of groups is at most 21((2k−1)−1)+1=k. We prove that k groups can be obtained. More precisely, excluding the card with k, the remaining cards can be divided into k−1 pairs such that each pair contains numbers of the form j,2k−j, j=1,…,k−1. Call such cards complementary.
Note that, once k is found, one can determine the parity of the number on each card. Let e.g. k be odd. Choose any card x and ask about the two cards k,x. If their average is an integer then x is odd, otherwise is even. The case of even k is analogous.
Let us show now how to find the complementary pairs Cj={j,2k−j}, j=1,…,k−1. Start with C1={1,2k−1} and C2={2,2k−2}. Take a pair of cards with different parity and unknown sum y; y is odd. Ask about the average of the remaining 2k−3 cards. It is an integer if and only if 2k−3 divides S−y=k(2k−1)−y=k(2k−3)+2k−y, hence if and only if 2k−3 divides 2k−y. Note that 3≤y≤4k−3, yielding ∣2k−y∣≤2k−3. So the answer is yes if and only if 2k−y∈{0,±(2k−3)}. Because 2k−y is odd (as y is), we obtain 2k−y=±(2k−3), yielding y=3 or y=4k−3. These are the extremal values of the sum y; they are achieved only if the numbers in the pair are 1,2 or 2k−2,2k−1 respectively.
By repeating this procedure with all pairs of cards with different parity we find the two pairs 1,2 and 2k−2,2k−1 (without knowing which one is which). Thus a group containing the 4 cards 1,2,2k−2,2k−1 is determined. It has 2 odd and 2 even numbers, and the parity of the number on each card is known. Hence the two odd cards in the group form the complementary pair C1={1,2k−1}, the two even cards form C2={2,2k−2}.
Suppose that the complementary pairs C1,…,C2j are determined for some j such that 2j≤k−1. We show how to find C2j+1 and C2j+2. One may assume 2j≤k−3. Indeed if 2j=k−1 (with k odd) then all complementary pairs are already found. If 2j=k−2 (with k even) then there is only 1 complementary pair left, Ck−1. But once Ck−1,…,Ck−2 are known, so is Ck−1.
Exclude the 4j numbers C1,…,C2j. There remain 2k−4j−1 numbers with sum S−4jk. Again take a pair of cards with different parity and unknown odd sum y; note that 4j+3≤y≤4k−4j−3. Like before ask about the average of the remaining 2k−4j−3 cards. It is an integer if and only if 2k−4j−3 divides (S−4jk)−y=k(2k−1)−4jk−y=k(2k−4j−3)+(2k−y), i.e., if and only if 2k−4j−3 divides 2k−y. Now 4j+3≤y≤4k−4j−3 gives ∣2k−y∣≤2k−4j−3. So the answer is yes if and only if 2k−y∈{0,±(2k−4j−3)}. Because 2k−y is odd, we obtain 2k−y=±(2k−4j−3), yielding y=4j+3 or y=4k−4j−3. These are the extremal values of y, achieved only if the numbers in the pair are 2j+1,2j+2 or 2k−2j−2,2k−2j−1 respectively.
Hence the procedure applied to all pairs of the kind considered, yields a group containing the 4 cards 2j+1,2j+2,2k−2j−2,2k−2j−1. The two odd cards in the group form the complementary pair C2j+1={2j+1,2k−2j−1}, the two even ones form C2j+2={2j+2,2k−2j−2}.
We presented an inductive argument which divides all cards different from k into complementary pairs. This completes the solution.