above is the problem
here i am not able to think what to do other than finding primes in the given range
Please help

After finding no of primes copy paste soln of . Set Q=No of Primes and N=No of non Primes.


You can read editorial of that Kgp regional problem.

Thanks man.
I got a idea ,to go further.
Did you also solve problem .
from same contest ,I am just able to think about brute force solution .how can optimise ?
Thanks in advance

Can someone help me understand what’s wrong with this submission of mine?

Question link :

Link to a similar solution that got AC:

Someone told me that same problem exists on codeforces but Idk exact link.
As far as what we did my teammate just wrote a backtracking soln and test cases were weak af to get AC.

Hey, can you explain, how the expected value is

N + Q - N/(Q+1)