Title
CodeForces 1401 C. Mere Array
Time Limit
2 seconds
Memory Limit
256 megabytes
Problem Description
You are given an array a 1 , a 2 , … , a n a_1, a_2, \dots, a_n a1,a2,…,an where all a i a_i ai are integers and greater than 0 0 0.
In one operation, you can choose two different indices i i i and j j j ( 1 ≤ i , j ≤ n 1 \le i, j \le n 1≤i,j≤n). If g c d ( a i , a j ) gcd(a_i, a_j) gcd(ai,aj) is equal to the minimum element of the whole array a a a, you can swap