시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 0 0 0 0.000%

문제

The Cybersoft Computer Company (a leader in programming languages) has hired you to work on a new programming language named A--. Your task is to work on the array mapping tasks of the language. You will take an array reference such as x[5,6] and map it to an actual physical address. In preparation for doing this, you will write a program that will read in several array declarations and references and give the physical address of each reference. The physical address output by the program should be an integer number in base 10.

The physical address of an array reference A[i1,i2,...,iD] is calculated from the formula C0 + C1i1 + C2i2 + ... + CDiD, where the constants C0...CD are calculated as specified below. 

  • B = Base address of the array 
  • D = Number of dimensions in the array
  • Ld = Lower bound of dimension d
  • Ud = Upper bound of dimension d

입력

The first line of the input file contains two positive integers

출력

The output file should contain the array references and the physical address. There should be one array reference and physical address per line. The formatting guidelines below must be adhered to. 

For each line of output:

  1. Output the name of the array
  2. Output a left square bracket
  3. Output each index value (each pair of indexes should have a single comma and space between them)
  4. Output a right square bracket, a space, an equal sign, and another space
  5. Output the physical address

예제 입력

3 4
ONE    1500 2 2 0 3 1 5
TWO    2000 4 3 1 4 0 5 5 10
THREE  3000 1 1 1 9
ONE    2 4
THREE  7
TWO    2 0 6
TWO    3 3 9

예제 출력

ONE[2, 4] = 1526
THREE[7] = 3006
TWO[2, 0, 6] = 2148
TWO[3, 3, 9] = 2376

힌트