This is link of problem NUMSET
Contest link
I write a solution and it is giving me WA :(.
now I am unable to find where I am wrong. I have seen the editorial but that is totally different.
this is my solution LINK
(sieve function in code has no use that was different approach that also gave me WA:( ).
My approach :-
- For every number I am finding count of numbers having GCD greater than 1(that are not co-prime).
- Now I am sorting the array according to count calculated in 1st step.
- I am taking all element from starting that are co-prime to all that i have taken for that I use set of all number that are not co-prime to added number.
Please let me know where I am going wrong or give me some test case in which my code is failing.
Thanks.