A. Co-prime Array

题意:给你一个数列,要求构造两两相邻之间的数互质的数列,可以插入的数的小于10的9次方

思路:其实可以选择靠近10的9次方的最大的三个素数、然后按我下面的方法做就可以了,我这里选的三个素数不是最大的,数据有点水,就水过了

 #include<cstdio>
#include<cstring>
#include<cmath>
const int qq=;
int num[qq];
int ar[qq<<];
int gcd(int x,int y)
{
return y==?x:gcd(y,x%y);
}
int main()
{
int n;scanf("%d",&n);
for(int i=;i<n;++i)
scanf("%d",&num[i]);
int c[]={,,};
ar[]=num[];
int k=;
for(int i=;i<n;++i){
int ans;
int x=num[i];
int y=ar[k-];
if(x>y) ans=gcd(x,y);
else ans=gcd(y,x);
if(ans==) ar[k++]=x;
else{
for(int j=;j<;++j){
if(c[j]%x!=&&c[j]%y!=){
ar[k++]=c[j];
break;
}
}
ar[k++]=x;
}
}
printf("%d\n",k-n);
for(int i=;i<k;++i)
printf("%d ",ar[i]);
printf("\n");
}

B. Seating On Bus

题意:这题就纯粹考英语了,读懂了就so easy,大概是说人去做公交车会先选择靠窗的位置坐下,靠窗的坐完了然后才会做靠近走廊的位置,途中也给出了座位标号的顺序,但是这里要求输出的顺序就不一样了, 要求比如一行的编号是 1 19 20 2 如果都有人的话输出的循序就是 19 1 20 2、

思路:先标记能坐多少人,然后按给定的输出顺序判断这地方有没有坐人就ok了

 #include<iostream>
#include<cstdio>
const int qq=;
int num[qq]={};
int main()
{
int n,m;
scanf("%d%d",&n,&m);
for(int i=;i<=m;++i)
num[i]=;
int fir=n*+,sec=n*+;
for(int i=;i<=(n<<);++i){
if(i%==){
if(num[fir]) printf("%d ",fir);
}
else if(i%==) {
if(num[fir-*n]) printf("%d ",fir-*n);
}
else if(i%==){
if(num[sec]) printf("%d ",sec);
}
else if(i%==){
if(num[sec-*n]) printf("%d ",sec-*n);
}
if(i%==){
fir=fir+;
sec=sec+;
}
}
printf("\n");
}

Educational Codeforces Round 11、A B题的更多相关文章

  1. Educational Codeforces Round 11 B. Seating On Bus 水题

    B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...

  2. Educational Codeforces Round 11 A. Co-prime Array 水题

    A. Co-prime Array 题目连接: http://www.codeforces.com/contest/660/problem/A Description You are given an ...

  3. Educational Codeforces Round 11 C hard process_补题——作为司老大的脑残粉

    司老大当时教了一种姿势枚举连续K个0,说实话当时比赛写这题完全蒙了 纵然后来知道思路还是写了一段时间 真的是.. 题目大意 n长度的序列,由0 1构成 我们可以改变 k个0为1 求可以得到的最长连续1 ...

  4. Educational Codeforces Round 11 _D

    http://codeforces.com/contest/660/problem/D 这个题据说是很老的题了 然而我现在才知道做法 用map跑了1953ms: 题目大意 给你n个点的坐标 求这些点能 ...

  5. Educational Codeforces Round 11 C. Hard Process 前缀和+二分

    题目链接: http://codeforces.com/contest/660/problem/C 题意: 将最多k个0变成1,使得连续的1的个数最大 题解: 二分连续的1的个数x.用前缀和判断区间[ ...

  6. Educational Codeforces Round 11

    A. Co-prime Array http://codeforces.com/contest/660/problem/A 题意:给出一段序列,插进一些数,使新的数列两两成互质数,求插最少的个数,并输 ...

  7. Educational Codeforces Round 11 E. Different Subsets For All Tuples 动态规划

    E. Different Subsets For All Tuples 题目连接: http://www.codeforces.com/contest/660/problem/E Descriptio ...

  8. Educational Codeforces Round 11 D. Number of Parallelograms 暴力

    D. Number of Parallelograms 题目连接: http://www.codeforces.com/contest/660/problem/D Description You ar ...

  9. Educational Codeforces Round 11 C. Hard Process 二分

    C. Hard Process 题目连接: http://www.codeforces.com/contest/660/problem/C Description You are given an a ...

随机推荐

  1. Djngo 请求的生命周期

    1.Django请求的生命周期 路由系统 -> 试图函数(获取模板+数据=>渲染) -> 字符串返回给用户 2.路由系统 /index/ -> 函数或类.as_view() / ...

  2. MySQL学习-- UNION与UNION ALL

    UNION用于把来自许多SELECT语句的结果组合到一个结果集合中,也叫联合查询. ? 1 2 3 4 5 SELECT ... UNION [ALL | DISTINCT] SELECT ... [ ...

  3. React 按需加载 - 代码分隔

    代码分隔 我们现在大多数React项目都是以Webpack 或者 Browserify等将一堆的jsx文件组织一起,并且由一个类似index.js的入口文件串联起来的单页面web页面. 例如: // ...

  4. [运维]ESXI系统的安装 标签: 虚拟机运维vmware服务器虚拟化 2017-05-05 09:24 496人阅读 评论(15)

    上篇博客说到了VMware vSphere,那么接下来就讲一下我们如何将之投入使用.vsphere的虚拟机管理程序就是esxi. 什么是ESXI? vSphere产品套件的核心产品是虚拟机管理程序,作 ...

  5. js将canvas保存成图片并下载

    <canvas id="canvas" width="400" height="400"></canvas> < ...

  6. Spring表达式语言:SpEl

    概念: 是一个支持运行时查询和操作的对象图的强大的表达式语言. 语法类似于EL:SpEl使用#{ ...}作为定界符,所有在大括号中的 字符都将被认为是SpEl SpEl为bean的属性进行动态赋值提 ...

  7. API管理的五大规则

    http://www.csdn.net/article/2012-12-18/2812929-5-Rules-For-API-Management 1. 设计 开发人员使用API访问各种不同的类,并且 ...

  8. Black-White-Blocks

    微信小程序黑白块游戏 代码如下: //play.js // play var app = getApp() Page({ data: { typeName: '计时模式', score: 0, tim ...

  9. vagrant up提示"Couldn't open file /path/to/base"的错误解决方法

    在vagrant使用命令vagrant up启动虚拟机时 出错: C:\Vagrant>vagrant up Bringing machine 'default' up with 'virtua ...

  10. Length of Last Word输出最后单词的字母个数

    Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...