22411_ISpeakWhales

2022-5-16 18:22| 发布者: Hocassian| 查看: 24| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506408052599-Problem List-采集的数据-后羿采集器.html

Pro.ID

22411

Title

I Speak Whales

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22411

AC

3

Submit

22

Ratio

13.64%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    According to Wikipedia, a Walsh matrix is a specific square matrix, with dimensions equal to a power of 2, the entries of which are +1 or -1, and the property that the dot product of any two distinct rows (or columns) is zero. Below are the first three Walsh Matrices. (The gray lines are imaginary lines for illustration purpose only.)

    A Walsh Matrix of size 2N+1 can be constructed as the "union" of 4 Walsh Matrices of size 2N arranged such that the lower right matrix is inverted whereas the other 3 matrices are not, i.e.:

    Let's number the rows of a given Walsh Matrix from the top starting with row 0. Similarly, let's number the columns of the matrix from the left starting with column 0. Given the four integers N, R, S, and E, write a program that will construct a Walsh Matrix of size 2N and will print the sum of all the numbers in row #R between columns #S and #E (inclusive.)

    输入

    Your program will be tested on one or more test cases. Each test case is specified using a single line listing four integers in the following order: N, R, S, and E, where 0 ≤ N ≤ 60, 0 ≤ R < 2N, 0 ≤ SE < 2N, and E - S ≤ 10,000.

    The last line of the input file has four -1's and is not part of the test cases.

    输出

    Description

    According to Wikipedia, a Walsh matrix is a specific square matrix, with dimensions equal to a power of 2, the entries of which are +1 or -1, and the property that the dot product of any two distinct rows (or columns) is zero. Below are the first three Walsh Matrices. (The gray lines are imaginary lines for illustration purpose only.)

    A Walsh Matrix of size 2N+1 can be constructed as the "union" of 4 Walsh Matrices of size 2N arranged such that the lower right matrix is inverted whereas the other 3 matrices are not, i.e.:

    Let's number the rows of a given Walsh Matrix from the top starting with row 0. Similarly, let's number the columns of the matrix from the left starting with column 0. Given the four integers N, R, S, and E, write a program that will construct a Walsh Matrix of size 2N and will print the sum of all the numbers in row #R between columns #S and #E (inclusive.)

    Input

    Your program will be tested on one or more test cases. Each test case is specified using a single line listing four integers in the following order: N, R, S, and E, where 0 ≤ N ≤ 60, 0 ≤ R < 2N, 0 ≤ SE < 2N, and E - S ≤ 10,000.

    The last line of the input file has four -1's and is not part of the test cases.

    Output

    For each test case, print the output on a single line.

    Sample Input

    2 1 0 1
    48 0 0 47
    -1 -1 -1 -1

    Sample Output

    0
    48

    Source

    样例输入

    2 1 0 1
    48 0 0 47
    -1 -1 -1 -1

    样例输出

    0
    48

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部