爬不出去的水井(0333)

Time limit(ms): 1000 Memory limit(kb): 65535 Submission: 1069 Accepted: 150

Description

有一只青蛙掉进了一口水井里,自然青蛙不想在水井里呆一辈子。于是它尝试从水井里跳出来。但是水井的墙壁又是十分的光滑,它每次跳上去之后变会滑落一段距离。已知青蛙每次可跳的高度为H,每次向上跳后在井壁滑落的距离为X,水井的高度为L!请你设计一个程序来计算青蛙多少次可以跳出水井!

例如:青蛙可跳的高度为3,每次滑落2,水井高5米。那么它需要跳3次即可出水井

Input

多组测试数据,每组测试数据一行,为L, H ,X(均为正整数)中间以空格隔,L水井的高度,H表示每次青蛙可跳的高度,X每次滑落的高度 
输入均为0时结束,即 0 0 0时程序结束

Output

对应每组测试数据,输出青蛙出水井所要跳的次数

Sample Input

5 3 2
7 4 1
 
Sample Output
3
2
 
Hint
Source
 
 #include<stdio.h>
int main()
{
int L,H,X;
while(scanf("%d %d %d",&L,&H,&X)!=EOF)
{
if(L==&&H==&&X==)
break;
if(L<=H)
printf("1\n");
else
{
if((L-H)%(H-X)==)
{
printf("%d\n",(L-H)/(H-X)+);
}
else
{
printf("%d\n",(L-H)/(H-X)+);
}
}
}
return ;
}

注:(count+1)* H - count * X = L,求 count+1,L<=H(也只有在这种情况下,H才可能等于X)处理下,模拟过程可能会超时。

 

SWUST OJ 爬不出去的水井(0333)的更多相关文章

  1. [Swust OJ 404]--最小代价树(动态规划)

    题目链接:http://acm.swust.edu.cn/problem/code/745255/ Time limit(ms): 1000 Memory limit(kb): 65535   Des ...

  2. [Swust OJ 649]--NBA Finals(dp,后台略(hen)坑)

    题目链接:http://acm.swust.edu.cn/problem/649/ Time limit(ms): 1000 Memory limit(kb): 65535 Consider two ...

  3. Jarvis OJ - 爬楼梯 -Writeup

    Jarvis OJ - 爬楼梯 -Writeup 本来是想逆一下算法的,后来在学长的指导下发现可以直接修改关键函数,这个题做完有种四两拨千斤的感觉,记录在这里 转载请标明出处:http://www.c ...

  4. SWUST OJ NBA Finals(0649)

    NBA Finals(0649) Time limit(ms): 1000 Memory limit(kb): 65535 Submission: 404 Accepted: 128   Descri ...

  5. [Swust OJ 1023]--Escape(带点其他状态的BFS)

    解题思路:http://acm.swust.edu.cn/problem/1023/ Time limit(ms): 5000 Memory limit(kb): 65535     Descript ...

  6. [Swust OJ 1125]--又见GCD(数论,素数表存贮因子)

    题目链接:http://acm.swust.edu.cn/problem/1125/ Time limit(ms): 1000 Memory limit(kb): 65535   Descriptio ...

  7. [Swust OJ 1126]--神奇的矩阵(BFS,预处理,打表)

    题目链接:http://acm.swust.edu.cn/problem/1126/ Time limit(ms): 1000 Memory limit(kb): 65535 上一周里,患有XX症的哈 ...

  8. [Swust OJ 1026]--Egg pain's hzf

      题目链接:http://acm.swust.edu.cn/problem/1026/     Time limit(ms): 3000 Memory limit(kb): 65535   hzf ...

  9. [Swust OJ 1139]--Coin-row problem

    题目链接:  http://acm.swust.edu.cn/contest/0226/problem/1139/ There is a row of n coins whose values are ...

随机推荐

  1. 给select赋值之后,再点击选择下拉值时,显示一值不变的解决

    在一个项目需求中,请求数据,得到的数据dataAll渲染到页面的select下拉表单中,当时是需要一进页面就要默认选中第一个选项,所以直接将dataAll的第一个索引值赋值给了表单的绑定值formVa ...

  2. 好看的UI组合,为以后自己写组件库做准备

    1. 黑色格子背景 { color: rgb(255, 255, 255); text-shadow: 1px 1px 0 rgba(0,0,0,.3); rgb(62, 64, 74); backg ...

  3. 使用python列出目录下的所有文件

    https://stackoverflow.com/questions/3964681/find-all-files-in-a-directory-with-extension-txt-in-pyth ...

  4. 获取cell上按钮事件

    原由:点击cell上的按钮,无法获取button对应的cell位置 //获取按钮上层控件,也就是cell本身 AccountCell *cell= (AccountCell *)[按钮名称 super ...

  5. SQL Server Driver for PHP之sqlsrv相关函数

    SQL Server Driver for PHP 包含以下函数: 函数 说明 sqlsrv_begin_transaction 开始事务. sqlsrv_cancel 取消语句:并放弃相应语句的所有 ...

  6. Python访问Amazon官网异常

    使用Python访问亚马逊(Amazon)官网,如果没有将headers更改为浏览器的信息, 有几率会触发:检测到当前可能是自动程序,需要输入验证码: 将header修改成浏览器后,需要等一段时间或者 ...

  7. c++ 语言几个坑

    #include <iostream> int main(){ int i = 1; switch (i){ case 1 : int j ; j = 1; break; case 2: ...

  8. EXAM-2018-08-21

    EXAM-2018-08-21 自己真的是菜的恐怖 D:Fence Building 欧拉公式:V-E+F=2 在平面中:V为顶点个数,E为边数,F为区域数 在简单几何体中:V为顶点个数,E为边数,F ...

  9. UIView的setNeedsLayout, layoutIfNeeded 和 layoutSubviews 方法之间的关系解释(转)

    layoutSubviews总结 ios layout机制相关方法 - (CGSize)sizeThatFits:(CGSize)size- (void)sizeToFit——————- - (voi ...

  10. Python数据分析与展示第2周学习笔记(北理工 嵩天)

    单元4:Matplotlib库入门 matplotlib.pyplot是绘制各类可视化图形的命令子库,相当于快捷方式 import matplotlib.pyplot as plt # -*- cod ...