Choose k elements fromff an array so that the GCD is maximise.

Revision en1, by Loserinlife, 2023-05-30 17:45:20

Choose k elements from an array so that their GCD is maximise.

Constraints: N <= 3000 K <= N <= 100 Ai <= 10^10 (ten to the power of 10) I tried an algorithm of enumerating all divisors of ai and find the largest divisors that exists in >= k elements but it TLE. Can somebody help? Thanks in advance.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Loserinlife 2023-05-30 17:59:01 4 Tiny change: '00\nK <= N <= 100\nA' -> '00\nK <= N; K <= 100\nA'
en1 English Loserinlife 2023-05-30 17:45:20 373 Initial revision (published)