SZU : A18 (Climb Well)
Judge Info
- Memory Limit: 32768KB
- Case Time Limit: 10000MS
- Time Limit: 10000MS
- Judger: Number Only Judger
Description
One day frog Frank fall into a deep well, the well is very deep. Everyday Frank try to climb up, at day time, he can get himself
feet up, but when he fall sleep at night , he slipped
feet down. The well is L feet deep.
Task
Now, it is your turn. Frank is asking you to find out, how many days needed for him to get out from the well. A day has two part, day time and night time. Frank must get higher than the well, or it is not count as get out.
Input
The first line of input contains
, the number of test cases. There is one line for each test case, contains three integer numbers
as describe above.
Output
For each test case, print a line contains the solution, how many days need for Frank to get out from the well.If there is no way out, please output −1.
Sample Input
2
2 1 2
1 1 2
Sample Output
2
-1
被误解的思路:
本以为 A 2 B 1 L 2 一天就可以爬过去,原来 刚好 A = L 是过不去井口的。所以要 > 井口才可以出的去。
代码:
#include<stdio.h> int main()
{
int A,B,L;
int t;
scanf("%d",&t);
while(t>)
{
scanf("%d%d%d",&A,&B,&L);
if(A<=B)
{
if(A<=L)
printf("-1\n");
else
printf("1\n");
}
else
{
if(A>L)
printf("1\n");
else
printf("%d\n",(int)((L-A)/(A-B))+);
}
t--;
} return ;
}
SZU : A18 (Climb Well)的更多相关文章
- 【暑假】[深入动态规划]UVa 12170 Easy Climb
UVa 12170 Easy Climb 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=24844 思路: 引别人一 ...
- P3436 [POI2006]PRO-Professor Szu
P3436 [POI2006]PRO-Professor Szu 题目描述 n个别墅以及一个主建筑楼,从每个别墅都有很多种不同方式走到主建筑楼,其中不同的定义是(每条边可以走多次,如果走边的顺序有一条 ...
- Easy Climb UVA - 12170 滚动dp +离散化+ 单调队列优化
E.Easy Climb Somewhere in the neighborhood we have a very nice mountain that gives a splendid view o ...
- [uva12170]Easy Climb
还是挺难的一个题,看了书上的解析以后还是不会写,后来翻了代码仓库,发现lrj又用了一些玄学的优化技巧. #include <algorithm> #include <iostream ...
- Easy Climb
题意: 有n块石头,给定他们的高度,现保持第一和最后一块高度不变,其他可增加和减少高度,求通过变换使所有相邻石头的高度差的绝对值不大于d,所变化高度总和的最小值. 分析: 状态还可以想出来,dp[i] ...
- SZU:B47 Big Integer II
Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Normal Descrip ...
- SZU:D89 The Settlers of Catan
Judge Info Memory Limit: 65536KB Case Time Limit: 3000MS Time Limit: 3000MS Judger: Number Only Judg ...
- SZU:B47 Big Integer I
Judge Info Memory Limit: 32768KB Case Time Limit: 10000MS Time Limit: 10000MS Judger: Normal Descrip ...
- SZU:G32 Mass fraction
Judge Info Memory Limit: 32768KB Case Time Limit: 5000MS Time Limit: 5000MS Judger: Float Numbers (1 ...
随机推荐
- Swift学习——Swift解释特定的基础(七)
Implicitly Unwrapped Optionals 隐式解析选项 如上所述.可选意味着常数或变量"没有值".通过可选if声明来推断是否存在值,假设有值析值. 有时候 ...
- UML对象图和包图
UML九已经介绍过的基本图,然后,我们再来看看对象图和包图. 一.对象图 谈到对象.我们不得不说一下对象.对象(Object)是对象类的实例(Instance),用于模型化特定的实体.对象是唯一的. ...
- JavaScript循环之for/in循环
今天学到了JavaScript的语句篇.同其他常见编程语言如C.Java等一样,JavaScript中的语句包含:①表达式语句②复合语句和空语句③声明语句④条件语句⑤循环语句⑥跳转语句,当然JavaS ...
- [Python 2.7] Hello World CGI HTTP Server
# CGI HTTP server ## Getting Started Python 2.x is preferred to this simple demo. I'm using Python 2 ...
- HDU 5037 FROG (贪婪)
Problem Description Once upon a time, there is a little frog called Matt. One day, he came to a rive ...
- mysql_oracle_随机查询几条记录
数据库的随机查询SQL 1. Oracle,随机查询20条 select * from ( select * from 表名 order by dbms_random.value ) where ...
- maven添加本地jar包依赖
1. 在java工程下新建文件夹,如repo/allin/allin-util/0.1 然后jar包扔进去,如下图: 2. 修改pom.xml文件,增加以下 <repositories> ...
- Tomcat剖析(三):连接器(2)
Tomcat剖析(三):连接器(2) 1. Tomcat剖析(一):一个简单的Web服务器 2. Tomcat剖析(二):一个简单的Servlet服务器 3. Tomcat剖析(三):连接器(1) 4 ...
- CSharp设计模式读书笔记(24):访问者模式(学习难度:★★★★☆,使用频率:★☆☆☆☆)
模式角色与结构: 示例代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; ...
- Group and sum array of hashes by date
I have an array of hashes like this: [{:created=>Fri, 22 Jan 2014 13:02:13 UTC +00:00, :amount=&g ...