水题。放个1就可以了。暴力的找数字也是很快的。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std; const int maxn=+;
long long a[maxn]; long long gcd(long long a,long long b)
{
if(b==) return a;
return gcd(b,a%b);
} int n; int main()
{
vector<long long>ans;
scanf("%d",&n);
for(int i=;i<=n;i++) scanf("%lld",&a[i]);
ans.push_back(a[]);
int cnt=;
for(int i=;i<=n;i++)
{
long long tmp=gcd(a[i],ans[ans.size()-]);
if(tmp==) ans.push_back(a[i]);
else
{
cnt++;
ans.push_back();
ans.push_back(a[i]);
}
}
printf("%d\n",cnt);
for(int i=;i<ans.size();i++) printf("%lld ",ans[i]);
printf("\n");
return ;
}

CodeForces 660A Co-prime Array的更多相关文章

  1. codeforces 660A A. Co-prime Array(水题)

    题目链接: A. Co-prime Array time limit per test 1 second memory limit per test 256 megabytes input stand ...

  2. Codeforces 442C Artem and Array(stack+贪婪)

    题目连接:Codeforces 442C Artem and Array 题目大意:给出一个数组,每次删除一个数.删除一个数的得分为两边数的最小值,假设左右有一边不存在则算作0分. 问最大得分是多少. ...

  3. Codeforces Round #504 D. Array Restoration

    Codeforces Round #504 D. Array Restoration 题目描述:有一个长度为\(n\)的序列\(a\),有\(q\)次操作,第\(i\)次选择一个区间,将区间里的数全部 ...

  4. Codeforces 660A. Co-prime Array 最大公约数

    A. Co-prime Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  5. Educational Codeforces Round 11A. Co-prime Array 数学

    地址:http://codeforces.com/contest/660/problem/A 题目: A. Co-prime Array time limit per test 1 second me ...

  6. Educational Codeforces Round 21 D.Array Division(二分)

    D. Array Division time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...

  7. Codeforces 754A Lesha and array splitting(简单贪心)

    A. Lesha and array splitting time limit per test:2 seconds memory limit per test:256 megabytes input ...

  8. Codeforces 408 E. Curious Array

    $ >Codeforces \space 408 E. Curious Array<$ 题目大意 : 有一个长度为 \(n\) 的序列 \(a\) ,\(m\) 次操作,每一次操作给出 \ ...

  9. Codeforces 946G Almost Increasing Array (树状数组优化DP)

    题目链接   Educational Codeforces Round 39 Problem G 题意  给定一个序列,求把他变成Almost Increasing Array需要改变的最小元素个数. ...

随机推荐

  1. make TARGET_PRODUCT=am335xevm OMAPES=4.x rowboat_clean 出现sgx相关的错误

    这些错误是一些链接错误,由于地址变更导致的软链接不对.所以只要更改下软链接的具体地址就可以.

  2. Servlet学习三:不允许直接访问jsp处理方式一过滤器

    转自:http://zy19982004.iteye.com/blog/1755189

  3. jQuery实现父窗口的问题

    因为先前遇到的问题,所以我考虑采用 IFRAME 来隔离不同的脚本,从而实现我需要的效果. 在框架中,我用 JavaScript 获取 JSON 数据,组织成 HTML 代码,最后将其填充至上层文档的 ...

  4. Tourists

    Tourists 时间限制: 5 Sec  内存限制: 64 MB 题目描述 In Tree City, there are n tourist attractions uniquely labele ...

  5. Swift 与 JSON 数据

    转载自: http://www.cnblogs.com/theswiftworld/p/4660177.html 我们大家平时在开发 App 的时候,相信接触最多的就是 JSON 数据了.只要你的 A ...

  6. HDU ACM 1495 非常可乐(广搜BFS)

    非常可乐 Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submissi ...

  7. FZU 2091 播放器(栈应用)

    栈基础应用 #include<iostream> #include<cstdio> #include<cstring> #include<vector> ...

  8. static加载问题

    原文地址:http://blog.csdn.net/lubiaopan/article/details/4802430     感谢原作者! static{}(即static块),会在类被加载的时候执 ...

  9. Linux学习 -- 日志管理

    日志服务 rsyslogd  CentOS6 取代了原来的syslog rsyslogd 默认启动.自启动 常用命令:lastb.lastlog.last.w.who.users. 系统默认日志 和 ...

  10. Windows API 之 FineFirstFile、FindNextFile

    参考:https://msdn.microsoft.com/en-us/library/aa364418%28VS.85%29.aspx FindFirstFile Searches a direct ...