编程介的小学生 2017-05-25 03:55 采纳率: 20.5%
浏览 655
已采纳

I Speak Whales

Problem 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 < 2^N , 0<=S<=E < 2^N , 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

  • 写回答

2条回答 默认 最新

查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog