CF894C 题解
思路
我们设
代码
# include <bits/stdc++.h>
using namespace std;
int n, a[1005], g;
int main () {
ios::sync_with_stdio (0);
cin.tie (0);
cout.tie (0);
cin >> n;
for (int i = 0; i < n; ++ i)
cin >> a[i], g = __gcd (g, a[i]);
for (int i = 0; i < n; ++ i)
if (a[i] == g)
goto there;
cout << "-1";
return 0;
there:
;
cout << n * 2 << '\n';
for (int i = 0; i < n; ++ i)
cout << g << ' ' << a[i] << ' ';
return 0;
}