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 ...
随机推荐
- 洛谷3953 (NOIp2017) 逛公园——记忆化搜索+用栈判0环
题目:https://www.luogu.org/problemnew/show/P3953 因为K只有50,所以想到用dp[ cr ][ j ]表示在点cr.比最短路多走了 j 的方案数.(看了TJ ...
- Hdu 1498 二分匹配
50 years, 50 colors Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- Postgresql 正则表达式【转】
原文:http://blog.csdn.net/wugewuge/article/details/7704996 postgresql支持POSIX 风格的正则表达式,在postgresql中使用正则 ...
- 使用Gradle构建项目
使用gradle构建项目之前,咱们先聊聊maven,使用maven构建项目和配置主要 接下来正式使用gradle来构建项目的和步骤: 1.下载源码 2.下载gradle 1.下载地址:https:// ...
- php手册常用的函数
<?php ************************************************************/ header("Content-type:tex ...
- Vue项目中出现Loading chunk {n} failed问题的解决方法
最近有个Vue项目中会偶尔出现Loading chunk {n} failed的报错,报错来自于webpack进行code spilt之后某些bundle文件lazy loading失败.但是这个问题 ...
- Leetcode925.Long Pressed Name长按键入
你的朋友正在使用键盘输入他的名字 name.偶尔,在键入字符 c 时,按键可能会被长按,而字符可能被输入 1 次或多次. 你将会检查键盘输入的字符 typed.如果它对应的可能是你的朋友的名字(其中一 ...
- WordPress使用自定义文章类型实现任意模板的方法和怎么做邮件回复
主要就是使用了register_post_type 函数. 1.创建插件目录 新建一个文件夹用来存放插件文件,这里我就命名这个文件夹为myMood 2.创php代码文件 在刚才创建的文件夹里面新建一个 ...
- 如何在Data Lake Analytics中使用临时表
前言 Data Lake Analytics (后文简称DLA)是阿里云重磅推出的一款用于大数据分析的产品,可以对存储在OSS,OTS上的数据进行查询分析.相较于传统的数据分析产品,用户无需将数据重新 ...
- 移动端的vh 和 vw简介和使用场景
vw 相对于视窗的宽度:视窗宽度是100vw:vh则类似,是相对于视窗的高度,视窗高度是100vh. 这里的视窗指的又是啥? 是浏览器内部宽度大小(window.innerWidth)? 是整个浏览器 ...