GCD of Cartesian product of two arrays

Revision en2, by Saucemaster102, 2022-09-15 23:13:28

hey guys , a while back I had come across this problem(sorry I don’t have the link to problem statement) , it was basically, given two arrays a and b of size n and m , find the gcd of all the elements of the resultant array c where c is the Cartesian product of a and b , I could not figure out a better approach than O(n*m) Does anyone have a better approach ?

Constraints : n,m<1e+5

Tags gcd

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Saucemaster102 2022-09-15 23:13:28 93
en1 English Saucemaster102 2022-09-15 23:09:19 351 Initial revision (published)