Let's denote the number of girls as \( G \) and the number of boys as \( B \). According to the problem, the ratio of girls to boys is \( 3:1 \). This means:
\[ \frac{G}{B} = \frac{3}{1} \]
From this, we can express the number of girls in terms of the number of boys:
\[ G = 3B \]
The total number of students is given as 400, so we can express this as:
\[ G + B = 400 \]
Now, substituting \( G \) from the first equation into the total students equation:
\[ 3B + B = 400 \]
This simplifies to:
\[ 4B = 400 \]
Now, divide both sides by 4:
\[ B = 100 \]
So there are 100 boys in the school.
To find the number of girls, we can substitute \( B \) back into the equation \( G = 3B \):
\[ G = 3 \times 100 = 300 \]
Thus, the results confirm that the total number of students is \( G + B = 300 + 100 = 400 \).
The number of boys is 100.