codeforces 652A A. Gabriel and Caterpillar(水题)
题目链接:
1 second
256 megabytes
standard input
standard output
The 9-th grade student Gabriel noticed a caterpillar on a tree when walking around in a forest after the classes. The caterpillar was on the height h1 cm from the ground. On the height h2 cm (h2 > h1) on the same tree hung an apple and the caterpillar was crawling to the apple.
Gabriel is interested when the caterpillar gets the apple. He noted that the caterpillar goes up by a cm per hour by day and slips down byb cm per hour by night.
In how many days Gabriel should return to the forest to see the caterpillar get the apple. You can consider that the day starts at 10 am and finishes at 10 pm. Gabriel's classes finish at 2 pm. You can consider that Gabriel noticed the caterpillar just after the classes at 2pm.
Note that the forest is magic so the caterpillar can slip down under the ground and then lift to the apple.
The first line contains two integers h1, h2 (1 ≤ h1 < h2 ≤ 105) — the heights of the position of the caterpillar and the apple in centimeters.
The second line contains two integers a, b (1 ≤ a, b ≤ 105) — the distance the caterpillar goes up by day and slips down by night, in centimeters per hour.
Print the only integer k — the number of days Gabriel should wait to return to the forest and see the caterpillar getting the apple.
If the caterpillar can't get the apple print the only integer - 1.
10 30
2 1
1
10 13
1 1
0
10 19
1 2
-1
1 50
5 4
1
In the first example at 10 pm of the first day the caterpillar gets the height 26. At 10 am of the next day it slips down to the height 14. And finally at 6 pm of the same day the caterpillar gets the apple.
Note that in the last example the caterpillar was slipping down under the ground and getting the apple on the next day.
AC代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int h1,h2,a,b;
scanf("%d%d",&h1,&h2);
scanf("%d%d",&a,&b);
h1+=*a;
if(h1<h2&&a<=b)cout<<"-1"<<endl;
else
{
int ans=;
while()
{
if(h1>=h2)
{
cout<<ans<<endl;
break;
}
h1-=*b;
h1+=*a;
ans++;
} } return ;
}
codeforces 652A A. Gabriel and Caterpillar(水题)的更多相关文章
- Educational Codeforces Round 7 B. The Time 水题
B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...
- Educational Codeforces Round 7 A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...
- Codeforces Testing Round #12 A. Divisibility 水题
A. Divisibility Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/probl ...
- Codeforces Beta Round #37 A. Towers 水题
A. Towers 题目连接: http://www.codeforces.com/contest/37/problem/A Description Little Vasya has received ...
- codeforces 677A A. Vanya and Fence(水题)
题目链接: A. Vanya and Fence time limit per test 1 second memory limit per test 256 megabytes input stan ...
- CodeForces 690C1 Brain Network (easy) (水题,判断树)
题意:给定 n 条边,判断是不是树. 析:水题,判断是不是树,首先是有没有环,这个可以用并查集来判断,然后就是边数等于顶点数减1. 代码如下: #include <bits/stdc++.h&g ...
- Codeforces - 1194B - Yet Another Crosses Problem - 水题
https://codeforc.es/contest/1194/problem/B 好像也没什么思维,就是一个水题,不过蛮有趣的.意思是找缺黑色最少的行列十字.用O(n)的空间预处理掉一维,然后用O ...
- Codeforces 1082B Vova and Trophies 模拟,水题,坑 B
Codeforces 1082B Vova and Trophies https://vjudge.net/problem/CodeForces-1082B 题目: Vova has won nn t ...
- CodeForces 686A Free Ice Cream (水题模拟)
题意:给定初始数量的冰激凌,然后n个操作,如果是“+”,那么数量就会增加,如果是“-”,如果现有的数量大于等于要减的数量,那么就减掉,如果小于, 那么孩子就会离家.问你最后剩下多少冰激凌,和出走的孩子 ...
随机推荐
- XtraBackup备份mysql5.1.73
一.基础介绍 mysql5.1在源码中配备了两个版本的innodb存储引擎源码:innobase和innodb_plugin,编译安装的时候可以通过参数--with-plugins=innobase, ...
- nginx 不能解析php怎么办
在服务器下源码安装了 mysql php nginx,结果nginx不支持php.解决方法,在nginx配置文件中添加: ocation ~ .*\.php?$ { fastcgi_pass 127 ...
- 使用CSDN CODE来存放OPENSTACK位于GITHUB上的源代码
use CSDN CODE to pull openstack codes 2014-11-20 Author:Hyphen 问题 直接从GITHUB上获代替码,常常是没保障,特别是用DEVSTACK ...
- Web前端开发规范【HTML/JavaScript/CSS】
前言 这是一份旨在增强团队的开发协作,提高代码质量和打造开发基石的编码风格规范,其中包含了 HTML, JavaScript 和 CSS/SCSS 这几个部分.我们知道,当一个团队开始指定并实行编码规 ...
- hdu 2036 改革春风吹满地【求多边形面积模板】
链接: http://acm.hdu.edu.cn/showproblem.php?pid=2036 http://acm.hust.edu.cn/vjudge/contest/view.action ...
- iOS源代码管理svn
01. SVN介绍 SVN 是集中式源代码管理工具 概念: 1> Repository 代码仓库,保存代码的仓库 2> Server 服务器,保存所有版本的代码仓库 3&g ...
- mysql设置指定ip远程访问连接的方法
本文实例讲述了mysql设置指定ip远程访问连接的方法,分享给大家供大家参考.具体实现方法如下: 1. 授权用户root使用密码jb51从任意主机连接到mysql服务器: 复制代码 代码如下: GRA ...
- interface -- 接口类
<?php /** *为了声明接口,需要使用关键字interface *interface IExampleInterface {} *说明(大多数开发人员选择在节后名称前加上大写字母I作为前缀 ...
- DEV开发之控件NavBarControl
右键点击RunDesigner弹出如下界面鼠标先点击3或4,1,,然后点击1或2进行相应的新增或删除操作,3是分组,4是项目,4可以直接拖动到相应的分组3.属性caption:显示的名称4.NavBa ...
- HTML入门学习笔记
1.html文件的基本架构 <HTML> <HEAD> <TITLE> 网页的标题 </TITLE> </HEAD> <BODY> ...