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. cf round 482E Kuro and Topological Parity

    题意:一个长度为$n$的序列,一些地方是$0$,一些地方是$1$,$-1$的地方你可以选择填$0$或者$1$,你可以选择连一些边$x->y$满足$x<y$ 请问有多少种填数并连边的方法,使 ...

  2. QT应用qmake添加应用图标

    总体解决方案: 1.搜索 [Setting the Application Icon]帮助 2.http://doc.qt.io/qt-5/appicon.html 3.可以在主pro文件中加入如下语 ...

  3. web前端学习(二)html学习笔记部分(6)--fileAPI

    1.2.18 html5 File API的应用 1.2.18.1  实现可选择列表 通过为列表项增加一个选择框,进而实现列表的多选和对选择文件的删除.同时,在选择.取消选择时实现操作栏的切换. 1. ...

  4. hdu 1045 Fire Net(二分匹配 or 暴搜)

    Fire Net Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Su ...

  5. Codeforces Round #429 (Div. 2) A. Generous Kefa【hash/判断字符串是否有一种字符个数大于m】

    A. Generous Kefa time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  6. RestController注解下返回到jsp视图页面(转)

    这个问题我也遇到过,下面的方法可以试试 蓝萝卜blu @RestController注解下返回到jsp视图页面 spring4.1中添加了@RestController注解很方便,集成了@Respon ...

  7. POJ3614 [USACO07NOV]防晒霜Sunscreen

    Sunscreen Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9333   Accepted: 3264 Descrip ...

  8. Sentinel 1.5.0 正式发布,引入 Reactive 支持

    近日,流控降级组件 Sentinel 的又一个里程碑版本 1.5.0 正式发布. 该版本引入 Reactive 的支持,并提供多项新特性与改进.从 1.5.0 版本开始,Sentinel 仅支持 JD ...

  9. This Product is covered by one or more of the folloWing patents

    借用一下网络图片,作为描述: 原因: 启动方式使用了网络启动, 解决方案: 进入bios,修改启动方式,禁用网卡驱动,使用从硬盘启动或者从U盘启动即可.

  10. Qt添加右键菜单

    QAction *hideAction = new QAction(tr(" 隐藏"),this); addAction(hideAction); setContextMenuPo ...