您的位置:首页 > 其它

SZU : A18 (Climb Well)

2013-07-07 16:12 211 查看

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>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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: