If there are $N$ doors of which $P$ contain a prize, the probability that you win if you don't switch is $P/N$. Suppose Monty then reveals $k$ randomly selected[*] non-prize doors (with $k\leq N-P-1$, which means he always has $k$ available doors to reveal).
Then there are two possibilities:
- Your original door contains a prize. This happens with probability $P/N$. Of the $N-k-1$ remaining doors, there will be $P-1$ which contain a prize, so the probability that this happens and then you win the prize after switching to a random unopened door is
$$
\frac{P}{N}\frac{P-1}{N-k-1}
$$
- Your original door does not contain a prize. This happens with probability $\frac{N-P}{N}$ and means that $P$ of the remaining doors contain prizes, so the probability that this happens and you win after switching is
$$
\frac{N-P}{N}\frac{P}{N-k-1}
$$
That is, your total probability of winning after switching is
$$
\frac{P}{N}\frac{P-1}{N-k-1}+\frac{N-P}{N}\frac{P}{N-k-1}=\frac{P^2-P+NP-P^2}{N(N-k-1)}=\frac{P(N-1)}{N(N-k-1)}
$$
So the inequality you're looking for is: you should switch when
$$
\frac{P(N-1)}{N(N-k-1)} \geq \frac{P}{N}
$$
That is, switching multiplies your probability of winning by a factor of $\frac{N-1}{N-k-1}$, which is always greater than $1$ when $k$ is positive. So you should always switch, a result which is not surprising as this problem is qualitatively the same as the original Monty Hall problem. In both cases, after Monty opens some doors, you have more information about the location of the prizes than you did before the doors were opened, so you have a better chance of making the right decision.
[*] If the doors Monty opens are not randomly selected, it is possible that he could leak some extra information to you about what to do based on them. For example, if you know that he's lazy and always opens the leftmost doors that he's allowed to, then you clearly want to switch to one of the doors that he skips over. I think that's beyond the intent of this question — but it might make a good follow-up!