• 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 }
  • 相关阅读:
    day43——celery简介、celery小例子
    day42——queue模块
    day41——多进程的消息队列、消息队列pipe
    在风口浪尖后,如何有效控制权限?
    微服务架构下代码管理规范
    微服务架构下介质管理规范
    微服务架构下组件管理规范
    微服务架构下文档管理规范
    微服务与DevOps关系
    Springboot集成SpringData JPA
  • 原文地址:https://www.cnblogs.com/firstrate/p/3176457.html
Copyright © 2020-2023  润新知