Recently, I was trying to solve a problem. To solve that I shall have to solve a sub problem. The sub problem is:
I will be provided some values. I want to find number of pairs possible for that set of values who have gcd>1
Can anyone suggest an efficient approach? I just want you to give me hints so that I can start from that point of view and move forward.
if the values are $$$\le 10^6$$$, you can try to check $$$d,2d,3d...$$$ for each $$$2\le d \le 10^6$$$
Can you please elaborate a little bit?
make the array $$$cnt$$$, where $$$cnt_d$$$ means the number of occurrences of value $$$d$$$ in the array.
And when you check $$$d$$$ and $$$2d$$$, whose gcd is $$$2$$$, the number of pairs they make is $$$cnt_d*cnt_{2d}$$$