Блог пользователя kien_coi_1997

Автор kien_coi_1997, 12 лет назад, По-английски

There is n integer elements. Choose k elements then calculate their GCD, call result X.

What is maximal value of X?

k<=n<=3000, k<=100, elements in range 1..10^10.

Example:

3 2
120
36
100

Sample output

20
Теги set
  • Проголосовать: нравится
  • +43
  • Проголосовать: не нравится

»
12 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +30 Проголосовать: не нравится

These constraints are in a very gray area, it really depends on the time limit. So depending on the limit you may or may not be able to:

Factor each number: Sieve of Eratosthenes + 3000 * (primes below 10 ^ 5) = 3000 * 10000; Generate divisors of each number in O(divisor_count). Divisor_count is at most 2300. Keep a frequency table for the divisors and just select the biggest one that's over k.

Just a first thought. It's a fragile solution, but it may very well work. Again, the constraints are too fuzzy. Will look for something cleaner and smarter though :).

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

ez