Suppose that a number n is perfect. It can be represented by its factorization as a product of pi^ki, where the pi are a finite set of distinct primes. The sum of the divisors of pi^ki is pi^ki+pi^(ki-1)+ ... +1, and it can easily be shown that σ(n) is the product of these sums for all of n's prime factors (because if a and b are co-prime, σ(ab)=σ(a)σ(b) ).
For n to be perfect, σ(n)=2n. Equivalently, the product of (pi^ki+pi^(ki-1)+ ... +1)/pi^ki for all i must equal 2.
If n is odd, so are all denominators in this product. This means that all numerators must also be odd, except for one that is 2 (mod 4). Because all pi are odd, all powers of pi are also odd, and the parity of pi^ki+pi^(ki-1)+ ... +1 is simply the parity of the number of summed elements, meaning that for it to be odd, ki must be even. These pi values contribute to the "(2m+1)2" part of the representation, because the corresponding pi^ki values are odd squares. The remaining pi equals "q". Its ki must be odd. Its pi^(ki-1) part, being an odd square, completes the "(2m+1)2" part of the representation.
In order to show that this is special form B, we still need to prove that q is congruent to 1 (mod 4). The reason for this is that otherwise the numerator for this particular pi would have been 0 (mod 4), contrary to the 2 (mod 4) assumption.
In contrast, n may be even. If it is, consider it as 2st, with odd t. Let p0=2, then the numerator for this prime is 2s+1-1, which we shall denote u. All prime factors of u must appear in the pi list (for their values in the denominator to cancel out the odd value that appears in the numerator), so the smallest odd pi must be smaller or equal to u. Let us call it p. Note that if p=u then 2su is a perfect number. This indicates t=u, because adding any further prime is adding another multiple that is larger than one to the product that calculates σ(n)/n, so the total product will be larger than 2. We can also not increase the power of p from 1, because pk+pk-1+...+1>p+1 for k>1, once again pushing the product above 2.
On the other hand, p can not be smaller than u, for this would indicate (p+1)/p>(u+1)/u, again pushing the product above 2. As before, adding more primes or increasing the power of p merely makes this problem worse.
Therefore, t=u must be a prime, so we conclude that n must be of special form A.