标签:
#include<cstdio>
#include<vector>
using namespace std;
const int maxn = 1000 + 10;
vector<int> a;
int gcd(int a,int b){
return b == 0?a:gcd(b,a%b);
}
int main(){
int n,tmp;
scanf("%d",&n);
for(int i = 0 ; i < n ; ++i){
scanf("%d",&tmp);
a.emplace_back(tmp);
}
int cnt = 0;
vector<int>::iterator itv;
for(itv = a.begin() + 1;itv != a.end();++itv){
if(gcd(*itv,*(itv - 1)) != 1){
itv = a.emplace(itv,1);
++cnt;
}
}
printf("%d\n",cnt);
for(itv = a.begin();itv != a.end();++itv){
printf("%d ",*itv);
}
return 0;
}
[2016-04-09][codeforces][660][A][ Co-prime Array]
标签:
原文地址:http://www.cnblogs.com/qhy285571052/p/6511d1e944733c4264f83d58017fdc51.html