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 A\, feet up, but when he fall sleep at night , he slipped B\,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 T(1 leq T leq 100), the number of test cases. There is one line for each test case, contains three integer numbers A,B,L(0 leq A,B,L leq 2^{31}-1) 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 是过不去井口的。所以要 > 井口才可以出的去。

代码:

 1 #include<stdio.h>
 2  
 3 int main()
 4 {
 5     int A,B,L;
 6     int t;
 7     scanf("%d",&t);
 8     while(t>0)
 9     {
10         scanf("%d%d%d",&A,&B,&L);
11         if(A<=B)
12         {
13             if(A<=L)
14                 printf("-1
");
15             else
16                 printf("1
");
17         }
18         else
19         {
20             if(A>L)
21                 printf("1
");
22             else
23                 printf("%d
",(int)((L-A)/(A-B))+2);
24         }
25         t--;
26     }
27  
28  
29 return 0;
30 }
原文地址:https://www.cnblogs.com/firstrate/p/3176457.html