• 水了一题


    今天第一次在codeforces上做,做了第一个,第二个总是有错误,看了看别人的代码,代码量比我的少多了。

    A.
    The New Year: Meeting Friends
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, the second friend lives at the pointx2, and the third friend lives at the point x3. They plan to celebrate the New Year together, so they need to meet at one point. What is the minimum total distance they have to travel in order to meet at some point and celebrate the New Year?

    It's guaranteed that the optimal answer is always integer.

    Input

    The first line of the input contains three distinct integers x1, x2 and x3 (1 ≤ x1, x2, x3 ≤ 100) — the coordinates of the houses of the first, the second and the third friends respectively.

    Output

    Print one integer — the minimum total distance the friends need to travel in order to meet together.

    Examples
    input
    7 1 4
    output
    6
    input
    30 20 10
    output
    20
    Note

    In the first sample, friends should meet at the point 4. Thus, the first friend has to travel the distance of 3 (from the point 7 to the point4), the second friend also has to travel the distance of 3 (from the point 1 to the point 4), while the third friend should not go anywhere because he lives at the point 4.

    #include <iostream>
    #include <cstdio>
    
    using namespace std;
    
    int main()
    {
        int x,y,z;
        while(~scanf("%d %d %d",&x,&y,&z)){
            int maxx=x>(y>z?y:z)? x:(y>z?y:z);
            int minn=x<(y<z?y:z)? x:(y<z?y:z);
            printf("%d
    ",maxx-minn);
        }
        return 0;
    }
    B. Text Document Analysis
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters.

    In this problem you should implement the similar functionality.

    You are given a string which only consists of:

    • uppercase and lowercase English letters,
    • underscore symbols (they are used as separators),
    • parentheses (both opening and closing).

    It is guaranteed that each opening parenthesis has a succeeding closing parenthesis. Similarly, each closing parentheses has a preceding opening parentheses matching it. For each pair of matching parentheses there are no other parenthesis between them. In other words, each parenthesis in the string belongs to a matching "opening-closing" pair, and such pairs can't be nested.

    For example, the following string is valid: "_Hello_Vasya(and_Petya)__bye_(and_OK)".

    Word is a maximal sequence of consecutive letters, i.e. such sequence that the first character to the left and the first character to the right of it is an underscore, a parenthesis, or it just does not exist. For example, the string above consists of seven words: "Hello", "Vasya", "and", "Petya", "bye", "and" and "OK". Write a program that finds:

    • the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
    • the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
    Input

    The first line of the input contains a single integer n (1 ≤ n ≤ 255) — the length of the given string. The second line contains the string consisting of only lowercase and uppercase English letters, parentheses and underscore symbols.

    Output

    Print two space-separated integers:

    • the length of the longest word outside the parentheses (print 0, if there is no word outside the parentheses),
    • the number of words inside the parentheses (print 0, if there is no word inside the parentheses).
    Examples
    input
    37
    _Hello_Vasya(and_Petya)__bye_(and_OK)
    output
    5 4


    input
    37
    _a_(_b___c)__de_f(g_)__h__i(j_k_l)m__
    output
    2 6


    input
    27
    (LoooonG)__shOrt__(LoooonG)
    output
    5 2


    input
    5
    (___)
    output
    0 0


    Note

    In the first sample, the words "Hello", "Vasya" and "bye" are outside any of the parentheses, and the words "and", "Petya", "and" and "OK" are inside. Note, that the word "and" is given twice and you should count it twice in the answer.

    待续。。。

    明天再看这个

  • 相关阅读:
    华为内部面试题库(20)
    华为内部面试题库(18)
    华为内部面试题库(14)
    华为内部面试题库(12)
    华为内部面试题库(16)
    华为内部面试题库(17)
    华为内部面试题库(11)
    华为内部面试题库(13)
    Windows 危险的注册表键
    逆向工程师要学什么?
  • 原文地址:https://www.cnblogs.com/TWS-YIFEI/p/5951157.html
Copyright © 2020-2023  润新知