Another ``easy'' problem P71960


Statement
 

pdf   zip

thehtml

Professor Oak is desperate, searching for easy problems. Unfortunately, he is asking for the help of some students whose understanding of the word “easy” is questionable. It may be the case with this problem...

You are given some basic operations, and you just have to compute the result. To make the problem “less trivial”, you must compute the result for several initial values.

Input

Input consists of several cases. Each case starts with the number of operations n and the number of initial values m. Follow n pairs of the kind + x, * x, / x, | x, & x and ^ x, where the last three are the usual or, and and xor bitwise operations. Follow the m initial numbers, all different, to which the operations must be applied.

Assume that n and m are between 1 and 105, and that all the given numbers are between 0 and 1015. For every case, there are at most 100 operations that are not bitwise (that is, that are +, *, or /). With the given cases, all the intermediate and final results will be between 0 and 1015. You will never be asked to divide by 0.

Output

For every case, and for every initial number, print the result of applying all the operations in order. Print a line with 10 dashes at the end of every case.

For instance, consider the first initial number (1) of the first case. The result (10) is produced by these steps: 1 + 10 = 11, 11 & 3 = 3, 3 ^ 2 = 1, 1 * 23 = 23, 23 | 12 = 31, and 31/3 = 10.

Public test cases
  • Input

    6 5
    + 10 & 3 ^ 2 * 23 | 12 / 3
    1
    2
    3
    4
    5
    
    1 1
    & 1000000000000000
    500000000000000
    

    Output

    10
    15
    25
    4
    10
    ----------
    426876803874816
    ----------
    
  • Information
    Author
    Víctor Conchello
    Language
    English
    Official solutions
    C++
    User solutions
    C++