CodeForces 660A Co-prime Array
水题。放个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的更多相关文章
- codeforces 660A A. Co-prime Array(水题)
题目链接: A. Co-prime Array time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces 442C Artem and Array(stack+贪婪)
题目连接:Codeforces 442C Artem and Array 题目大意:给出一个数组,每次删除一个数.删除一个数的得分为两边数的最小值,假设左右有一边不存在则算作0分. 问最大得分是多少. ...
- Codeforces Round #504 D. Array Restoration
Codeforces Round #504 D. Array Restoration 题目描述:有一个长度为\(n\)的序列\(a\),有\(q\)次操作,第\(i\)次选择一个区间,将区间里的数全部 ...
- Codeforces 660A. Co-prime Array 最大公约数
A. Co-prime Array time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- 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 ...
- 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 ...
- Codeforces 754A Lesha and array splitting(简单贪心)
A. Lesha and array splitting time limit per test:2 seconds memory limit per test:256 megabytes input ...
- Codeforces 408 E. Curious Array
$ >Codeforces \space 408 E. Curious Array<$ 题目大意 : 有一个长度为 \(n\) 的序列 \(a\) ,\(m\) 次操作,每一次操作给出 \ ...
- Codeforces 946G Almost Increasing Array (树状数组优化DP)
题目链接 Educational Codeforces Round 39 Problem G 题意 给定一个序列,求把他变成Almost Increasing Array需要改变的最小元素个数. ...
随机推荐
- 转 dos 下的 find 和 重定向
1.find /i "ora-" *.* > check.log 附录: 我对findstr是如此的依赖,以至于当我向各位讲解find命令的时候,我还得老老实实地在cmd窗口 ...
- 【dfs 回溯】 zoj 1004
题意:给出一个源字符串和一个目标字符串,打出所有符合stack操作的i,o串使得对于源字符串的操作能变为目标字符串 思路:搜索,回溯. 之前想过是不是队列,觉得不对那样bfs是求最优解了:也想过用结构 ...
- log4j打印出线程号和方法名
先参考实现配置,如果想要更加详细的配置,可加上更多参数: log4j.rootLogger = INFO,FILE,CONSOLE log4j.appender.FILE.Threshold=INFO ...
- 【HDU 5833】Zhu and 772002(异或方程组高斯消元讲解)
题目大意:给出n个数字a[],将a[]分解为质因子(保证分解所得的质因子不大于2000),任选一个或多个质因子,使其乘积为完全平方数.求其方法数. 学长学姐们比赛时做的,当时我一脸懵逼的不会搞……所以 ...
- HDU 2018 undefined
题目思路:完全背包,dp[i][j]代表,砍j只怪,用i点疲劳最多能获得的经验值. 和平常的完全背包不一样的是多了一个限制条件:最多只砍S只怪,所以我们应该多一重循环来q:for 1->S,代表 ...
- iOS 多语言 浅析
什么是本地化处理? 本地化处理就是我们的应用程序有可能发布到世界的很多国家去,因为每个国家应用的语言是不一样的,所以我们要把我们的应用程序的语言要进行本地化处理一下. 本地化处理需要处理那些文件? ( ...
- openURL in APP Extension
var responder = self as UIResponder? while (responder != nil){ if responder!.respondsToSelector(Sele ...
- 初识Selenium(一)
Selenium入门相关PPT参考网址:http://wenku.baidu.com/view/d1e7d90390c69ec3d5bb7565.html?from=search 内容引用网址:htt ...
- NDK Build 用法(NDK Build)
1.ndk-build的用法 Android NDKr4引入了一个新的.小巧的shell脚本ndk-build,来简化源码编译. 该文件位于NDK根目录,进入你的工程根目录或子目录之后,在命令行下调用 ...
- java 对象的组合,一个类组合到另一个类中(例如手机卡装到手机上)
Example4_9.java public class Example4_9 { public static void main(String args[]) { SIM simOne = new ...