水题。放个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. zf-分页后台代码

    java : public ResultPage getDeptList(int page, int pageRows) throws Exception { String hql="fro ...

  2. java操作oracle的blob,clob数据

    一.区别和定义 LONG: 可变长的字符串数据,最长2G,LONG具有VARCHAR2列的特性,可以存储长文本一个表中最多一个LONG列 LONG RAW: 可变长二进制数据,最长2G CLOB:  ...

  3. Linux试题及答案

    一. 单选题: 1.添加一条静态路由,使到网络196.199.3通过eth2接口出去,用: A. route add -net 196.199.3.0 B. route add -net 196.19 ...

  4. set -x /set +x(linux)

    Linux 脚本中生成日志 set -x Posted on 2012-07-25 09:44 紫冰龙 阅读(3946) 评论(0) 编辑 收藏 set -x 与 set +x 在liunx脚本中可用 ...

  5. Swift 学习笔记 (三) 之循环引用浅析

    原创:转载请注明出处 110.自动引用计数实践 下面的例子展示了自动引用计数的工作机制.例子以一个简单的Person类开始,并定义了一个叫name的常量属性: class Person {     l ...

  6. Swift 学习笔记 (一)

    原创: 转载请注明出处 Extention try catch rxSwift internal  public  private var  let as       as? 强转 ? ! didSe ...

  7. Tomcat 虚拟目录映射

    最近老是被一个旧Ant工程所困扰,代码版本都改好了测试也通过了,就是打不了war包,一看build.xml 我的天 各种逆天啊....头大.于是乎想起了最基础的tomcat虚拟目录虽是一个很基础的点, ...

  8. cocos2d-x 3.x 触摸事件

    HelloWorldScene.h bool touchBegan(cocos2d::Touch*touch, cocos2d::Event*event);//触摸开始,返回bool类型 void t ...

  9. linux 命令实现原理

    我们知道有些Linux的命令涉及到一些高效率的算法,在此做出一个积累吧,不是系统的. 1.tail命令打印一个文件的最后num行 2.grep命令从文本中匹配字符串 基于正则表达式的匹配很快. it ...

  10. Review Board的使用

    代码审核工具.先在命令行界面,进入到工程的Main目录下,然后使用命令 svn diff>yus.diff  这样就将Main里面的所有内容生成了,然后在浏览器里进入到自己的Review Boa ...