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 ...
随机推荐
- golang时间与日期相关函数
- 入职9月,旷视孙剑106分钟讲述CV创业科研的5大区别
雷锋网按:本文为旷视科技首席科学家孙剑日前在 CCF-ADL上做的题为<如何在大公司和创业公司做好计算机视觉研究>的分享,主要介绍了近期计算机视觉的发展现状,ResNet基本原理和设计,旷 ...
- Python数据分析与展示[第三周](pandas数据特征分析单元8)
数据理解 基本统计 分布/累计统计 数据特征 数据挖掘 数据排序 操作索引的排序 .sort_index() 在指定轴上排序,默认升序 参数 axis=0 column ascending=True ...
- spark-ML基础
一.ML组件 ML的标准API使用管道(pipeline)这样的方式,可以将多个算法或者数据处理过程整合到一个管道或者一个流程里运行,其中包含下面几个部分: 1. dataFrame:用于ML的dat ...
- SQLServer —— 流程控制语句
一.IF - ELSE 语法: IF(条件) BEGIN 语句1 语句2 ... END ELSE BEGIN 语句1 语句2 ... END 说明: ELSE是可选部分,如果有多条语句,才需要BEG ...
- JAVA-WEB-错误之-'OPTION SQL_SELECT_LIMIT=DEFAULT'
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version ...
- JasperStudio study..
https://blog.csdn.net/shiyun123zw/article/details/79166448
- springboot thymeleaf【转】【补】
thymeleaf模板 https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html 1.引入thymeleaf依赖 <!-- ...
- [Java]ssh网上商城总结 标签: hibernatessh 2016-05-15 21:03 1099人阅读 评论(32)
前几日敲完了ssh网上商城,虽然现在已经敲完了整个系统,却发现自己对于ssh,了解的一点都不多,什么是struts2,什么是spring,什么是hibernate,自己都是稀里糊涂,然后看了一下后面的 ...
- Java练习 SDUT-2733_小鑫の日常系列故事(二)——石头剪子布
小鑫の日常系列故事(二)--石头剪子布 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 小鑫在上幼儿园的时候,喜欢跟小伙 ...