Playing with cards problem


please check

@bhattanurag426 you cannot update vector like you are doing in line 30, 42 and 46. you need to use push_back to store that stacks in vector.

no it worked …

https://ide.codingblocks.com/s/463956 made this change but worked only for case 0

sorry it only worked for the given case and case 2

while creating sieve you should store atleast q prime numbers but you are storing prime numbers that are smaller than or equal to q and whose count may be less than q so you won’t have q prime numbers in your vector and hence will give you run error if you try to access index larger than prime vector size.

https://ide.codingblocks.com/s/463956 now test case 1 is not runnung

again you are making the same mistake,it is not necessary that qth prime number will be less than n.
Just store all prime numbers till 10^5 it will work.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.