SZU : A18 (Climb Well)
2013-07-07 16:12
211 查看
Judge Info
Memory Limit: 32768KBCase 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![](http://acm.szu.edu.cn/wiki/images/math/7/b/8/7b80ebccd4420d9579e7d488396b7f5c.png)
feet up, but when he fall sleep at night , he slipped
![](http://acm.szu.edu.cn/wiki/images/math/d/5/7/d5742827d055e40cd568fd71271f4681.png)
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![](http://acm.szu.edu.cn/wiki/images/math/8/c/d/8cd9c6955e56c09def8c6a0b44986886.png)
, the number of test cases. There is one line for each test case, contains three integer numbers
![](http://acm.szu.edu.cn/wiki/images/math/b/3/c/b3c83e4b33fc739d94f78454deff1423.png)
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>0) { 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))+2); } t--; } return 0; }
相关文章推荐
- SZU : A18 (Climb Well)
- Problem(A18):Climb Well In SZUOJ青蛙爬井
- YT14-HDU-The snail climb well
- User Group Ready To Rock as well
- API CommDlgExtendedError Well, thed1
- API CommDlgExtendedError Well, youd1
- MooTools Plays Well With Rails
- PlusWell HA-Mirror产品规格及服务等级
- plus well双机下DELL MD3000i的安装与配置
- what is worth doing is worth doing well
- The primary key can work with the index well
- Happiness wellbeing
- 一些试验性CSS属性一【well】
- 《Team Geek: A Software Developer's Guide to Working Well with Others》读书笔记(二)
- Which would you perfer? "easy and fast and works well" or "hard and time consuming and error prone"
- SZU:B85 Alec's Eggs
- ibatiS启动的异常 The content of elements must consist of well-formed character data or markup
- JSF简单实例及无法正常访问的解决方法(404和The markup in the document preceding the root element must be well-formed. )
- SZU:A66 Plastic Digits
- Codeforces Round #139 (Div. 2) B. Well-known Numbers