Cubical subsets

I am trying to solve this problem can anyone please help me how to approach this problem.

The Problem is :
You are given two sets of numbers A and B. You should find a subset A’ of A and another subset B’ of B such that :
1.A’ and B’ are non-empty
2. For each element in A’ and each element in B’, a*b is a perfect cube.
3.|A’|^2 + |B’|^2 is maximised

Example Input:
A=2,16,5
B=4,4

Output:
8

6 Likes

yes same

1 Like

Can you please send code for that question

code please for above question