We are given that the student has answered correctly. We want to find the probability that he did not tick the answer randomly, i.e., he knew the correct answer.
Let \( A \) be the event that the student knows the correct answer, and \( B \) be the event that the student answers correctly.
Step 1: Use Bayes' Theorem
Bayes' Theorem gives the probability of \( A \) given \( B \) as:
\[
P(A \mid B) = \frac{P(B \mid A) P(A)}{P(B)}
\]
Step 2: Calculate the necessary probabilities
- \( P(A) = p \), the probability that he knows the correct answer.
- \( P(B \mid A) = 1 \), the probability of answering correctly given that he knows the answer.
- \( P(B \mid A^c) = \frac{1}{5} \), the probability of answering correctly when he does not know the answer, as he randomly guesses.
- \( P(A^c) = 1 - p \), the probability that he does not know the answer.
Step 3: Calculate \( P(B) \)
Using the law of total probability:
\[
P(B) = P(B \mid A) P(A) + P(B \mid A^c) P(A^c) = p + \frac{1}{5} (1 - p)
\]
\[
P(B) = p + \frac{1 - p}{5} = \frac{5p + 1 - p}{5} = \frac{4p + 1}{5}
\]
Step 4: Apply Bayes' Theorem
Now, applying Bayes' Theorem:
\[
P(A \mid B) = \frac{1 \times p}{\frac{4p + 1}{5}} = \frac{5p}{4p + 1}
\]
Thus, the correct answer is \( \frac{5p}{4p + 1} \).