• A. Two Elevators


    time limit per test

    1 second

    memory limit per test

    256 megabytes

    input

    standard input

    output

    standard output

    Vlad went into his appartment house entrance, now he is on the 11-th floor. He was going to call the elevator to go up to his apartment.

    There are only two elevators in his house. Vlad knows for sure that:

    • the first elevator is currently on the floor aa (it is currently motionless),
    • the second elevator is located on floor bb and goes to floor cc (b≠cb≠c). Please note, if b=1b=1, then the elevator is already leaving the floor 11 and Vlad does not have time to enter it.

    If you call the first elevator, it will immediately start to go to the floor 11. If you call the second one, then first it will reach the floor cc and only then it will go to the floor 11. It takes |x−y||x−y| seconds for each elevator to move from floor xx to floor yy.

    Vlad wants to call an elevator that will come to him faster. Help him choose such an elevator.

    Input

    The first line of the input contains the only tt (1≤t≤1041≤t≤104) — the number of test cases.

    This is followed by tt lines, three integers each aa, bb and cc (1≤a,b,c≤1081≤a,b,c≤108, b≠cb≠c) — floor numbers described in the statement.

    Output

    Output tt numbers, each of which is the answer to the corresponding test case. As an answer, output:

    • 11, if it is better to call the first elevator;
    • 22, if it is better to call the second one;
    • 33, if it doesn't matter which elevator to call (both elevators will arrive in the same time).

    Example

    input

    Copy

     
    

    3

    1 2 3

    3 1 2

    3 2 1

    output

    Copy

    1
    3
    2
    

    Note

    In the first test case of the example, the first elevator is already on the floor of 11.

    In the second test case of the example, when called, the elevators would move as follows:

    • At the time of the call, the first elevator is on the floor of 33, and the second one is on the floor of 11, but is already going to another floor;
    • in 11 second after the call, the first elevator would be on the floor 22, the second one would also reach the floor 22 and now can go to the floor 11;
    • in 22 seconds, any elevator would reach the floor 11.

    In the third test case of the example, the first elevator will arrive in 22 seconds, and the second in 11.

    解题说明:水题,直接计算两个电梯的耗时,然后比较即可,第二部电梯需要分别计算b大于c和b小于c的情况。

    1. #include
    2. #include
    3. int main()
    4. {
    5. int t;
    6. scanf("%d", &t);
    7. while (t--)
    8. {
    9. int a, b, c, m;
    10. scanf("%d%d%d", &a, &b, &c);
    11. if (b >= c)
    12. {
    13. m = b;
    14. }
    15. else
    16. {
    17. m = (c + c - b);
    18. }
    19. if (a == m)
    20. {
    21. printf("3\n");
    22. }
    23. else if (a < m)
    24. {
    25. printf("1\n");
    26. }
    27. else
    28. {
    29. printf("2\n");
    30. }
    31. }
    32. return 0;
    33. }

  • 相关阅读:
    进销存管理系统是什么?能给企业带来哪些好处?
    最短路径算法
    mysql复习
    【华为OD机试真题 python】 免单统计【2022 Q4 | 100分】
    安全面试之XSS(跨站脚本攻击)
    c语言小项目(三子棋游戏实现)
    树状数组与线段树模板集合
    计算机网络(四、网络层)
    ChatGpt的初步认知(认知搬运工)
    CentOS7使用技巧
  • 原文地址:https://blog.csdn.net/jj12345jj198999/article/details/127136487