I am stuck with this problem. Can anyone help me please.

Problem: Calculate a sequence B from array A such that gcd(b[i], b[j]) = 1.

Example A = 1, 6, 4, 2, 8

Output B = 1, 5, 1, 3, 8

A[i]<30 (Constraints)

Please provide the solution in C++

I am stuck with this problem. Can anyone help me please.

Problem: Calculate a sequence B from array A such that gcd(b[i], b[j]) = 1.

Example A = 1, 6, 4, 2, 8

Output B = 1, 5, 1, 3, 8

A[i]<30 (Constraints)

Please provide the solution in C++

Link to the probkem?

This was asked in an contest. I donâ€™t have the link sorry.

Can you please provide me the solution??