CF1148G.Gold Experience

NOI/NOI+/CTSC

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Consider an undirected graph GG with nn vertices. There is a value aia_i in each vertex.

Two vertices ii and jj are connected with an edge if and only if gcd(ai,aj)>1gcd(a_i, a_j) \gt 1, where gcd(x,y)gcd(x, y) denotes the greatest common divisor (GCD) of integers xx and yy.

Consider a set of vertices. Let's call a vertex in this set fair if it is connected with an edge with all other vertices in this set.

You need to find a set of kk vertices (where kk is a given integer, 2⋅k≤n2 \cdot k \le n) where all vertices are fair or all vertices are not fair. One can show that such a set always exists.

考虑一个包含 nn 个顶点的无向图 GG。每个顶点 ii 上有一个值 aia_i。

当且仅当 gcd⁡(ai,aj)>1\gcd(a_i, a_j) > 1 时,顶点 ii 与顶点 jj 之间存在一条边,其中 gcd⁡(x,y)\gcd(x, y) 表示整数 xx 与 yy 的最大公约数(GCD)。

考虑一组顶点。若该组中某个顶点与该组内其余所有顶点均通过边相连,则称该顶点为公平的(fair)。

你需要找出一个包含 kk 个顶点的集合(其中 kk 是给定的整数,满足 2⋅k≤n2 \cdot k \le n),使得该集合中所有顶点均为公平的,或所有顶点均不为公平的。可以证明,这样的集合总是存在的。

输入格式

The first line contains integers nn and kk (6≤2⋅k≤n≤1056 \leq 2 \cdot k \leq n \leq 10^5) — the number of vertices and parameter kk.

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (2≤ai≤1072 \le a_i \le 10^7) — the values in the vertices.

第一行包含两个整数 nn 和 kk(满足 6≤2⋅k≤n≤1056 \leq 2 \cdot k \leq n \leq 10^5)—— 分别表示顶点数量和参数 kk。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(满足 2≤ai≤1072 \le a_i \le 10^7)—— 表示各顶点上的数值。

输出格式

Print exactly kk distinct integers — the indices of the vertices in the chosen set in any order.

恰好输出 kk 个互不相同的整数——即所选顶点集合中各顶点的索引(顺序任意)。

输入输出样例

  • 输入#1

    6 3
    6 15 10 8 14 12

    输出#1

    1 3 6
  • 输入#2

    8 4
    11 15 10 6 21 15 10 6

    输出#2

    1 2 3 4
  • 输入#3

    10 5
    3003 17017 3230 49742 546 41990 17765 570 21945 36465

    输出#3

    4 6 9 10 1

说明/提示

In the first test case, set 2,4,5{2, 4, 5} is an example of set where no vertices are fair. The vertex 22 does not share an edge with vertex 44 since gcd(15,8)=1gcd(15, 8) = 1. The vertex 44 does not share an edge with vertex 22. The vertex 55 does not share an edge with vertex 22.

In the second test case, set 8,5,6,4{8, 5, 6, 4} is an example of a set where all vertices are fair.

在第一个测试用例中,集合 {2,4,5}\{2, 4, 5\} 是一个不存在公平顶点的集合示例。顶点 22 与顶点 44 之间没有边相连,因为 gcd⁡(15,8)=1\gcd(15, 8) = 1;顶点 44 与顶点 22 之间也没有边相连;顶点 55 与顶点 22 之间同样没有边相连。

在第二个测试用例中,集合 {8,5,6,4}\{8, 5, 6, 4\} 是一个所有顶点均为公平顶点的集合示例。

输入解题思路,AI测评打分。不知道怎么写?

首页