Educational Codeforces Round 10 A B题、
A. Gabriel and Caterpillar
题意: 就是说 一个小孩子去观察毛毛虫从 h1的地方爬到h2的地方、毛毛虫从10点爬到22点、每小时爬的距离是a, 晚上22点到第二天早上10点 毛毛虫休息 每小时下落b距离、但是最初状态是那个小孩子从14点开始观察毛毛虫的, 必须过了24点才算一天
思路:模拟、但细节地方要注意
hint:但你要知道什么情况下永远也爬不上去,就是说每小时下落比每小时上升的距离大呢,但这还有个细节, 就是即使b>a 但毛毛虫是先可以爬10个小时,如果在这10个小时内爬到了h2 也就是说 及时b>a它也可以爬到
#include<iostream>
#include<cstdio>
#include<cmath>
int main()
{
int n,m;
int a,b;
while(~scanf("%d%d%d%d",&n,&m,&a,&b)){
int ans=m-n;
int flag=; //标记变量、记录是否能爬到终点
int distance=;
int time=;
distance+=a*;
if(distance<ans){
while(){
distance-=b*; //休息
++time; // 休息时间过了24点、 所以算一天
distance+=a*;
if(distance>=ans) break;
if(b>=a){ //直接在循环里面判断、 因为前面可以爬的10小时可以到终点的话
flag=; // 也就不会进循环了
break;
}
}
}
if(!flag) printf("-1\n");
else printf("%d\n",time);
}
}
B. z-sort
题意:先给你一个数列、问用着数列的数是否可以组成一个 对于数列中每一个偶数项 存在ai ≥ ai - 1、对于每一个奇数项 存在ai ≤ ai - 1思路:我是这样想的、既然要满足两个条件、 那么对于从前到后的奇数项来说是一个非递减的,对前到后的偶数项来说是一个非递增的、
那么对于所给的数列、 排一个序,然后贪心,具体看代码吧
#include<cmath>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int num[];
int main()
{
int n;scanf("%d",&n);
for(int i=;i<=n;++i)
scanf("%d",&num[i]);
sort(num+,num+n+);
int ans[];
int add,dre;
add=;
dre=n;
for(int i=;i<=n;++i) //构造这样一个数列
if(i%==)
ans[i]=num[dre--];
else
ans[i]=num[add++];
int flag=;
// for(int i=1;i<=n;++i)
// printf("%d ",ans[i]);
// printf("\n");
for(int i=;i<=n;++i) //判断构造的数列是否满足条件
if(i%==){
if(ans[i]<ans[i-]) flag=;
}
else
if(ans[i]>ans[i-]) flag=;
if(!flag) printf("Impossible");
else for(int i=;i<=n;++i) printf("%d ",ans[i]);
printf("\n");
return ;
}
C D 题意其实都看懂了、 就是做不出来 好气好气阿,
读题方面比以前好一点了、
继续努力吧、
Educational Codeforces Round 10 A B题、的更多相关文章
- Educational Codeforces Round 10 C. Foe Pairs 水题
C. Foe Pairs 题目连接: http://www.codeforces.com/contest/652/problem/C Description You are given a permu ...
- Educational Codeforces Round 10
A:Gabriel and Caterpillar 题意:蜗牛爬树问题:值得一提的是在第n天如果恰好在天黑时爬到END,则恰好整除,不用再+1: day = (End - Begin - day0)/ ...
- Educational Codeforces Round 10 A. Gabriel and Caterpillar 模拟
A. Gabriel and Caterpillar 题目连接: http://www.codeforces.com/contest/652/problem/A Description The 9-t ...
- Educational Codeforces Round 23 A-F 补题
A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...
- Educational Codeforces Round 10 D. Nested Segments (树状数组)
题目链接:http://codeforces.com/problemset/problem/652/D 给你n个不同的区间,L或者R不会出现相同的数字,问你每一个区间包含多少个区间. 我是先把每个区间 ...
- CF Educational Codeforces Round 10 D. Nested Segments 离散化+树状数组
题目链接:http://codeforces.com/problemset/problem/652/D 大意:给若干个线段,保证线段端点不重合,问每个线段内部包含了多少个线段. 方法是对所有线段的端点 ...
- Educational Codeforces Round 10 D. Nested Segments 离线树状数组 离散化
D. Nested Segments 题目连接: http://www.codeforces.com/contest/652/problem/D Description You are given n ...
- Educational Codeforces Round 10 B. z-sort 构造
B. z-sort 题目连接: http://www.codeforces.com/contest/652/problem/B Description A student of z-school fo ...
- Educational Codeforces Round 10 D. Nested Segments 【树状数组区间更新 + 离散化 + stl】
任意门:http://codeforces.com/contest/652/problem/D D. Nested Segments time limit per test 2 seconds mem ...
随机推荐
- 转:Android新特性介绍,ConstraintLayout完全解析
转:http://blog.csdn.net/guolin_blog/article/details/53122387 本篇文章的主题是ConstraintLayout.其实ConstraintLay ...
- HTML input type=file文件选择表单的汇总(一)
HTML input type=file 在onchange上传文件的过程中,遇到同一个文件二次上传无效的问题. 最近在做项目过程中,遇到同一文件上传的时候,二次上传没有效果,找了资料,找到了原因: ...
- php收集表单数据-$GET和$POST的区别
学习笔记: $_GET 变量 预定义的 $_GET 变量用于收集来自 method="get" 的表单中的值. 从带有 GET 方法的表单发送的信息(例如:http://www.r ...
- 【JZOJ5068】【GDSOI2017第二轮模拟】树 动态规划+prufer序列
题面 有n个点,它们从1到n进行标号,第i个点的限制为度数不能超过A[i]. 现在对于每个s (1 <= s <= n),问从这n个点中选出一些点组成大小为s的有标号无根树的方案数. 10 ...
- vuehomework1
红黄蓝三个按钮,点击不同的按钮可以切换一个200*200的矩形框对应的颜色 <!DOCTYPE html> <html lang="en"> <hea ...
- 学习JDK1.8集合源码之--LinkedHashSet
1. LinkedHashSet简介 LinkedHashSet继承自HashSet,故拥有HashSet的全部API,LinkedHashSet内部实现简单,核心参数和方法都继承自HashSet,只 ...
- 【Vue】详解组件的基础与高级用法
Vue.js 最核心的功能就是组件(Component),从组件的构建.注册到组件间通信,Vue 2.x 提供了更多方式,让我们更灵活地使用组件来实现不同需求. 一.构建组件 1.1 组件基础 一个组 ...
- [PHPCMS V9二次开发]自定义字段模型-添加字段类型
步骤/方法 打开phpcms\modules\content\fields目录,复制文件夹downfiles,并改名为textgroups. 打开phpcms\modules\content\fiel ...
- 微信小程序 —— wepy 使用 Vant Weapp
一.下载 npm i @vant/weapp -S --production 下载完毕之后,就可以在 node_modules 文件夹里,看见下载的包了. 2.移动文件夹 把刚刚下载的包文件夹下的 l ...
- 掀开SQL的神秘面纱,将优化进行到底
掀开SQL的神秘面纱,将优化进行到底 有这样一条奇怪的SQL,返回结果不足10行,逻辑读达到1.2w,存在索引却走多次全表扫描,如何揭开它神秘的面纱拯救系统性能,答案在这里,你不可错过! 本文来自上周 ...