Educational Codeforces Round 11、A B题
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题的更多相关文章
- Educational Codeforces Round 11 B. Seating On Bus 水题
B. Seating On Bus 题目连接: http://www.codeforces.com/contest/660/problem/B Description Consider 2n rows ...
- 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 ...
- Educational Codeforces Round 11 C hard process_补题——作为司老大的脑残粉
司老大当时教了一种姿势枚举连续K个0,说实话当时比赛写这题完全蒙了 纵然后来知道思路还是写了一段时间 真的是.. 题目大意 n长度的序列,由0 1构成 我们可以改变 k个0为1 求可以得到的最长连续1 ...
- Educational Codeforces Round 11 _D
http://codeforces.com/contest/660/problem/D 这个题据说是很老的题了 然而我现在才知道做法 用map跑了1953ms: 题目大意 给你n个点的坐标 求这些点能 ...
- Educational Codeforces Round 11 C. Hard Process 前缀和+二分
题目链接: http://codeforces.com/contest/660/problem/C 题意: 将最多k个0变成1,使得连续的1的个数最大 题解: 二分连续的1的个数x.用前缀和判断区间[ ...
- Educational Codeforces Round 11
A. Co-prime Array http://codeforces.com/contest/660/problem/A 题意:给出一段序列,插进一些数,使新的数列两两成互质数,求插最少的个数,并输 ...
- 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 ...
- Educational Codeforces Round 11 D. Number of Parallelograms 暴力
D. Number of Parallelograms 题目连接: http://www.codeforces.com/contest/660/problem/D Description You ar ...
- Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process 题目连接: http://www.codeforces.com/contest/660/problem/C Description You are given an a ...
随机推荐
- 【Mobius绮丽的辗转】莫比乌斯反演
Problem 对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数. 1≤n≤50000,1≤a≤b≤5 ...
- Loadrunner常用分析点
Loadrunner常用的分析点 一.在Vuser(虚拟用户状态)中 1.Running Vusers:提供了生产负载的虚拟用户运行状态的相关信息,可以帮助我们了解负载生成的结果.(即用户在几分钟左右 ...
- PHP 中的 curl 函数发送 Post 请求应该注意的几点
public function http_request( $url, $post = '', $timeout = 5 ){ if( empty( $url ) ){return ;}$ch = c ...
- 10分钟学会Python
#1. 语法 Python中没有强制的语句终止字符,代码块是通过缩进来指示的.缩进表示一个代码块的开始,逆缩进则表示一个代码块的结束.一般用4个空格来表示缩进. 声明以冒号(:)字符结束,并且开启一个 ...
- Java 和 DynamoDB
https://docs.aws.amazon.com/zh_cn/amazondynamodb/latest/developerguide/GettingStarted.Java.html 官方
- Directx教程(25) 简单的光照模型(4)
原文:Directx教程(25) 简单的光照模型(4) 在本篇日志中,我们尝试用不带衰减的点光源来计算漫反射颜色. 前面的三个工程,我们都用的是方向光源(directional li ...
- python已安装包的查看方法和requirements.text的使用
1.已经安装包的查看方法 命令pip freeze 2. 批量导出命令 pip freeze >requirements.txt 3. 批量导入命令 pip install -r requir ...
- Linux上编辑然后执行一段脚本的机制
简要分析下刚开始提出的第二个问题, 因为没看代码,所以只是简单流程 1. 在bash里打开vim编辑文件并保存退出: bash进程fork子进程, 然后调用exec装入vim程序,wait这个子进程v ...
- JavaScript实现,控制一个文本框只能输入正整数,如输入不符合条件则文本框全部字体标红
腾讯2014年研发职位笔试题Web前端方向简单题第一题. 代码: <html> <head> <title>test JavaScript</title> ...
- 【JZOJ4835】【GDOI2017模拟10.31】量化交易
题目描述 数据范围 解法 贪心: 从左往右枚举,设枚举到元素为x,并维护一个堆: 设此时堆顶元素为y, 如果x大于y,那么x可以与y产生差价,立即将差价贡献给答案. 如果y之前已经和其他元素z产生过差 ...