Given a positive integer $n$, all of its positive integer divisors are written on a board. Two players $A$ and $B$ play the following game:

Each turn, each player colors one of these divisors either red or blue. They may choose whichever color they wish, but they may only color numbers that have not been colored before. The game ends once every number has been colored. $A$ wins if the product of all of the red numbers is a perfect square, or if no number has been colored red, $B$ wins otherwise. If $A$ goes first, determine who has a winning strategy for each $n$.
1. **Restate the problem in terms of divisors and vectors:**
   Given a positive integer \( n \), let \( n = \prod_{i=1}^{k} p_i^{\alpha_i} \) where \( p_i \) are prime factors and \( \alpha_i \) are their respective powers. Each divisor \( d \) of \( n \) can be represented as \( d = \prod_{i=1}^{k} p_i^{\beta_i} \) where \( 0 \leq \beta_i \leq \alpha_i \). We can map each divisor \( d \) to a vector \( (\beta_1, \ldots, \beta_k) \) in \( \mathbb{Z}_2^k \) by reducing each \( \beta_i \) modulo 2.

2. **Game rules in vector terms:**
   Each player colors one of these vectors either red or blue. \( A \) wins if the sum of the vectors corresponding to red numbers is zero (i.e., the product of red numbers is a perfect square) or if no number is colored red. \( B \) wins otherwise.

3. **Case 1: \( n \) is a perfect square:**
   - If \( n \) is a perfect square, all \( \alpha_i \) are even. Thus, each \( \alpha_i \) can be written as \( 2m_i \) for some integer \( m_i \).
   - The number of divisors of \( n \) is \( \prod_{i=1}^{k} (\alpha_i + 1) \), which is odd since each \( \alpha_i + 1 \) is odd.
   - There is a unique vector with odd multiplicity. \( A \) can color this vector blue in his first move and then imitate \( B \)'s moves. This ensures that the sum of the red vectors remains zero, so \( A \) wins.

4. **Case 2: \( n \) is neither a perfect square nor a prime power:**
   - The number of divisors of \( n \) is even, so \( B \) has the last move.
   - \( B \) can ensure that the sum of the red vectors is non-zero by choosing non-zero vectors in his last move.
   - The total number of zero vectors is less than half the number of divisors, so \( B \) can always choose non-zero vectors before his last move.

5. **Case 3: \( n = p^\alpha \) with \( \alpha \) odd:**
   - The number of divisors is \( \alpha + 1 \), which is even.
   - If \( \alpha = 1 \), then \( n \) is a prime, and \( A \) wins by coloring the only divisor blue.
   - If \( \alpha \geq 3 \), then there are \( m = \frac{\alpha + 1}{2} \) zeroes and \( m \) ones on the board.
   - \( B \) can always choose a number different from the one chosen by \( A \) in the previous move, ensuring that the game reduces to the case \( m = 2 \).
   - In the case \( m = 2 \), \( B \) can always win by choosing the same number and same color as \( A \) in the previous move if he wants a zero sum, or the same number and opposite color if he wants a non-zero sum.

Conclusion:
- \( A \) wins if and only if \( n \) is either a perfect square or a prime.

The final answer is \( \boxed{ A } \) wins if and only if \( n \) is either a perfect square or a prime.