Power or XOR? Solution | Codeforces Problem Solution 2022
The symbol is quite ambiguous, especially when used without context. Sometimes it is used to denote a power () and sometimes it is used to denote the XOR operation ().
You have an ambiguous expression . You can replace each symbol with either a operation or a operation to get an unambiguous expression .
The value of this expression is determined according to the following rules:
- All operations are performed before any operation. In other words, the operation takes precedence over operation. For example, .
- Consecutive powers are calculated from left to right. For example, .
You are given an array of length and an integer . The array is given by and the expression is given by . You need to find the XOR of the values of all possible unambiguous expressions which can be obtained from and has at least symbols used as operation. Since the answer can be very large, you need to find it modulo . Since this number can also be very large, you need to print its binary representation without leading zeroes. If the answer is equal to , print .
The first line of input contains two integers and .
The second line of input contains integers .
No comments:
Post a Comment