Educational Codeforces Round 10 A B题、

时间:2023-01-30 11:34:24

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题、的更多相关文章

  1. Educational Codeforces Round 10 C&period; Foe Pairs 水题

    C. Foe Pairs 题目连接: http://www.codeforces.com/contest/652/problem/C Description You are given a permu ...

  2. Educational Codeforces Round 10

    A:Gabriel and Caterpillar 题意:蜗牛爬树问题:值得一提的是在第n天如果恰好在天黑时爬到END,则恰好整除,不用再+1: day = (End - Begin - day0)/ ...

  3. Educational Codeforces Round 10 A&period; Gabriel and Caterpillar 模拟

    A. Gabriel and Caterpillar 题目连接: http://www.codeforces.com/contest/652/problem/A Description The 9-t ...

  4. Educational Codeforces Round 23 A-F 补题

    A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...

  5. Educational Codeforces Round 10 D&period; Nested Segments &lpar;树状数组&rpar;

    题目链接:http://codeforces.com/problemset/problem/652/D 给你n个不同的区间,L或者R不会出现相同的数字,问你每一个区间包含多少个区间. 我是先把每个区间 ...

  6. CF Educational Codeforces Round 10 D&period; Nested Segments 离散化&plus;树状数组

    题目链接:http://codeforces.com/problemset/problem/652/D 大意:给若干个线段,保证线段端点不重合,问每个线段内部包含了多少个线段. 方法是对所有线段的端点 ...

  7. Educational Codeforces Round 10 D&period; Nested Segments 离线树状数组 离散化

    D. Nested Segments 题目连接: http://www.codeforces.com/contest/652/problem/D Description You are given n ...

  8. Educational Codeforces Round 10 B&period; z-sort 构造

    B. z-sort 题目连接: http://www.codeforces.com/contest/652/problem/B Description A student of z-school fo ...

  9. Educational Codeforces Round 10 D&period; Nested Segments 【树状数组区间更新 &plus; 离散化 &plus; stl】

    任意门:http://codeforces.com/contest/652/problem/D D. Nested Segments time limit per test 2 seconds mem ...

随机推荐

  1. 星云opencv总结

  2. mac下需要安装旧 Java&&num;160&semi;SE&&num;160&semi;6 才能打开程序解决办法

    今天我在mac系统下面安装myeclipse2014(myeclipse-pro-2014-GA-offline-installer-macosx.dmg)的时候,发现显示错误: 您需要安装旧 Jav ...

  3. 【web前端面试题整理02】前端面试题第二弹袭来,接招!

    前言 今天本来准备先了解下node.js的,但是,看看我们一个小时前与一个小时后的差距: 既然如此,我们继续来搜集我们的前端面试题大业吧!!! 特别感谢玉面小肥鱼提供哟,@玉面小飞鱼 题目一览 Jav ...

  4. ios学习笔记

    1.对于autorelease的理解 Each thread in a Cocoa application maintains its own stack of autorelease pool bl ...

  5. hdu 5492 Find a path(dp&plus;少量数学)2015 ACM&sol;ICPC Asia Regional Hefei Online

    题意: 给出一个n*m的地图,要求从左上角(0, 0)走到右下角(n-1, m-1). 地图中每个格子中有一个值.然后根据这些值求出一个最小值. 这个最小值要这么求—— 这是我们从起点走到终点的路径, ...

  6. php 接口 implements 使用

    主要对类名,类所拥有的方法,以及所传参数起约束和规范做用,感觉跟php abstract 抽象类又有点像. 一,接口的定义和调用 <?php interface face1 { const pa ...

  7. python 学习 有序字典

    自定义创建有序字典类 dict的__getitem__方法 有些不同,想使用自定义__getitem__方法显示查询key的下标:需要研究 #/usr/bin/env python3 # -*- co ...

  8. git遇到的问题

    push代码时出现的问题: ! [remote rejected] HEAD -> (unpacker error)) 解决办法: $ git push --no-thin origin rel ...

  9. max of 直线划平面

    在一个无限延伸平面上有一个圆和n条直线,这些直线中每一条都在一个圆内,并且同其他所有的直线相交,假设没有3条直线相交于一点,试问这些直线最多将圆分成多少区域. Input 第一行包含一个整数T,(0& ...

  10. Spring将Bean导入IOC容器

    @Import 注解可以普通类导入到 IoC容器中. 想要让一个普通类接受 Spring 容器管理,有以下方法 使用 @Bean 注解 使用 @Controller @Service @Reposit ...