hlep[A C++ problem] #123488
Replies: 4 comments 4 replies
-
#include using namespace std; int gcd(int a, int b) { bool can_eliminate(int a[], int n) { int main() { |
Beta Was this translation helpful? Give feedback.
-
This is the wrong code |
Beta Was this translation helpful? Give feedback.
-
bool can_eliminate(int a[], int n) { |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Question
Body
Title: Eliminating a Sequence of Numbers
Problem Description:
Given a sequence of length$n$ , $a$ .
A single operation is defined as selecting three integers$x,y,z\in[1,n]$ , where $\gcd(a_x,a_y)=a_z$ and $x,y,z$ are all different, and then eliminating $a_z$ (i.e., $a_z$ cannot be selected for further operations).
Is it possible to eliminate$n-2$ numbers from the sequence $a_1\sim a_n$ after a certain number of operations?
Input Format:
The first line contains a positive integer$T$ , indicating the number of data sets.
For each data set,
The first line contains a positive integer$n$ .
The second line contains$n$ positive integers $a_i$ .
Output Format:
For each data set, output a line with a string
Yes
orNo
.Sample Input:
Sample Output:
Hint:
Data Range:
This problem has$20$ test cases, each with a score of $5$ .
For$100%$ of the data, $1\le T\le 10^5$ , $2\leq n \leq 10^6$ , $2 \le \sum n\le 10^6$ , $1\le a_i\le 10^9$ .
Beta Was this translation helpful? Give feedback.
All reactions