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 ...
随机推荐
- reverse 的用法
直接对数组或是数据结构使用 #include<bits/stdc++.h> using namespace std; ]={,,,,,};//申请6个元素,下标从0开始,最后一个下标是5 ...
- SQLServer2005 没有日志文件(*.ldf) 只有数据文件(*.mdf) 恢复数据库的方法
代码如下: exec sp_attach_db exun,'d:\exun2.mdf' (可能执行一次不能成功,测试了下,有时候需要执行2次以上命令才行) 执行了之后,记得刷新数据库,不然是不会显示的
- Django框架Day1------之url和views
一.新建一个Django程序(window 7进入cmd里面操作):注意,此处要需在指定的文件夹下 a,django-admin startproject django_test(django_tes ...
- PHP核心编程--目录操作(包含文件操作)
一.目录操作 1. 创建目录 创建目录mkdir(目录名称) //返回值为布尔 一次性创建主目录及其子目录 判断是不是一个目录is_dir //返回true,false 判断目录或文件是否存 ...
- thrift python安装
http://thrift.apache.org/download/ tar -zxvf thrift-0.11.0.tar.gz cd thrift-0.11.0 ./configure --pre ...
- java时间还在用date和calender?换LocalDateTime吧!
java在时间计算上一直为人所诟病,在社区强烈反应下,java8推出了线程安全.简易.高可靠的时间包.并且数据库中也支持LocalDateTime类型,所以在数据存储时候使时间变得简单. LocalD ...
- 阿里云发布敏感数据保护产品SDDP,数据贴身防护实现“外防内控”
数据安全问题,尤其是个人信息保护问题,一直是所有企业和个人关注的重点问题,7月10日,阿里云针对云上企业正式发布一款敏感数据保护产品SDDP(Sensitive Data Detection and ...
- 如何在“代码”视图中工作并充分利用 Dreamweaver 的编码功能。如 Emmet 缩写
可通过多种方式在 Dreamweaver 中处理代码. 您可以使用“新建文档”对话框打开新的代码文件,然后开始键入您的代码. 在 Dreamweaver 中创建新的代码文件 键入时,会显示代码提示以帮 ...
- Python发送邮件1(带附件的)
普通的发邮件(不使用类)
- jsp项目中整个项目没有问题但是servlet报错
项目没问题但是serverlet报错 项目右键 buildPath-->configure build path -->Myeclipse Library-->J2EE 1.3 Li ...