310008: CF1771C. Hossam and Trainees

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Hossam and Trainees

题意翻译

有 $T$ 组数据,每组数据给出 $n$ 和长度为 $n$ 的数列 $a_i$,判断有没有两个数不互质,如果有输出 "YES",没有输出 "NO"

题目描述

Hossam has $ n $ trainees. He assigned a number $ a_i $ for the $ i $ -th trainee. A pair of the $ i $ -th and $ j $ -th ( $ i \neq j $ ) trainees is called successful if there is an integer $ x $ ( $ x \geq 2 $ ), such that $ x $ divides $ a_i $ , and $ x $ divides $ a_j $ . Hossam wants to know if there is a successful pair of trainees. Hossam is very tired now, so he asks you for your help!

输入输出格式

输入格式


The input consists of multiple test cases. The first line contains a single integer $ t $ ( $ 1 \le t \le 10^5 $ ), the number of test cases. Description of the test cases follows. The first line of each test case contains an integer number $ n $ ( $ 2 \le n \le 10^5 $ ). The second line of each test case contains $ n $ integers, the number of each trainee $ a_1, a_2, \dots, a_n $ ( $ 1 \le a_i \le 10^9 $ ). It is guaranteed that the sum of $ n $ over all test cases does not exceed $ 10^5 $ .

输出格式


Print the answer — "YES" (without quotes) if there is a successful pair of trainees and "NO" otherwise. You can print each letter in any case.

输入输出样例

输入样例 #1

2
3
32 48 7
3
14 5 9

输出样例 #1

YES
NO

说明

In the first example, the first trainee and the second trainee make up a successful pair: $ a_1 = 32, a_2 = 48 $ , you can choose $ x = 4 $ .

Input

题意翻译

有 $T$ 组数据,每组数据给出 $n$ 和长度为 $n$ 的数列 $a_i$,判断有没有两个数不互质,如果有输出 "YES",没有输出 "NO"

Output

**题意翻译**

给定 $ T $ 组数据,每组数据包含一个整数 $ n $ 和一个长度为 $ n $ 的数列 $ a_i $,需要判断是否存在两个数不互质。如果存在这样的两个数,输出 "YES",否则输出 "NO"。

**题目描述**

Hossam 有 $ n $ 个学员,每个学员都有一个编号 $ a_i $。

如果存在一个整数 $ x $($ x \geq 2 $),这个整数既能整除 $ a_i $ 又能整除 $ a_j $,那么第 $ i $ 个和第 $ j $ 个学员($ i \neq j $)组成的学员对被称为成功的。

Hossam 想知道是否有一个成功的学员对。由于他现在很累,所以向你求助!

**输入输出格式**

**输入格式**

输入包含多个测试用例。第一行包含一个整数 $ t $($ 1 \le t \le 10^5 $),表示测试用例的数量。接下来是每个测试用例的描述。

每个测试用例的第一行包含一个整数 $ n $($ 2 \le n \le 10^5 $)。

每个测试用例的第二行包含 $ n $ 个整数,表示每个学员的编号 $ a_1, a_2, \dots, a_n $($ 1 \le a_i \le 10^9 $)。

保证所有测试用例的 $ n $ 之和不超过 $ 10^5 $。

**输出格式**

如果存在一个成功的学员对,输出 "YES"(不加引号),否则输出 "NO"。每个字母可以是大写或小写。

**输入输出样例**

**输入样例 #1**

```
2
3
32 48 7
3
14 5 9
```

**输出样例 #1**

```
YES
NO
```

**说明**

在第一个样例中,第一个和第二个学员组成一个成功的学员对:

$ a_1 = 32, a_2 = 48 $,你可以选择 $ x = 4 $。**题意翻译** 给定 $ T $ 组数据,每组数据包含一个整数 $ n $ 和一个长度为 $ n $ 的数列 $ a_i $,需要判断是否存在两个数不互质。如果存在这样的两个数,输出 "YES",否则输出 "NO"。 **题目描述** Hossam 有 $ n $ 个学员,每个学员都有一个编号 $ a_i $。 如果存在一个整数 $ x $($ x \geq 2 $),这个整数既能整除 $ a_i $ 又能整除 $ a_j $,那么第 $ i $ 个和第 $ j $ 个学员($ i \neq j $)组成的学员对被称为成功的。 Hossam 想知道是否有一个成功的学员对。由于他现在很累,所以向你求助! **输入输出格式** **输入格式** 输入包含多个测试用例。第一行包含一个整数 $ t $($ 1 \le t \le 10^5 $),表示测试用例的数量。接下来是每个测试用例的描述。 每个测试用例的第一行包含一个整数 $ n $($ 2 \le n \le 10^5 $)。 每个测试用例的第二行包含 $ n $ 个整数,表示每个学员的编号 $ a_1, a_2, \dots, a_n $($ 1 \le a_i \le 10^9 $)。 保证所有测试用例的 $ n $ 之和不超过 $ 10^5 $。 **输出格式** 如果存在一个成功的学员对,输出 "YES"(不加引号),否则输出 "NO"。每个字母可以是大写或小写。 **输入输出样例** **输入样例 #1** ``` 2 3 32 48 7 3 14 5 9 ``` **输出样例 #1** ``` YES NO ``` **说明** 在第一个样例中,第一个和第二个学员组成一个成功的学员对: $ a_1 = 32, a_2 = 48 $,你可以选择 $ x = 4 $。

加入题单

算法标签: