QOJ.ac

QOJ

حد الوقت: 4.0 s حد الذاكرة: 512 MB مجموع النقاط: 100

#11741. GCD

الإحصائيات

给定一个整数数组 $a_1, a_2, \dots, a_n$。

若你可以从数组中删除不超过 $k$ 个元素(其中 $k \le \frac{n}{2}$),求剩余元素的最大公约数的最大可能值。

输入格式

第一行包含两个整数:$n$(数组中元素的个数)和 $k$(最多可以删除的元素个数),满足 $2 \le n \le 10^5$,$0 \le k \le \frac{n}{2}$。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$(数组 $a$),满足 $1 \le a_i \le 10^{18}$。

输出格式

输出删除不超过 $k$ 个元素后,剩余所有元素的最大公约数的最大可能值。

样例

样例输入 1

4 1
6 15 35 14

样例输出 1

1

样例输入 2

4 2
6 15 35 14

样例输出 2

7

样例输入 3

3 1
897612484786617600 5828 16027

样例输出 3

1457

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#207EditorialOpen题解jiangly2025-12-13 00:12:54View

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.