GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Saturday, 30 April 2022

Power or XOR? Solution | Codeforces Problem Solution 2022

E. Power or XOR?
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

The symbol  is quite ambiguous, especially when used without context. Sometimes it is used to denote a power (ab=ab) and sometimes it is used to denote the XOR operation (ab=ab).

You have an ambiguous expression E=A1A2A3An. You can replace each  symbol with either a Power operation or a XOR operation to get an unambiguous expression E.

The value of this expression E is determined according to the following rules:

  • All Power operations are performed before any XOR operation. In other words, the Power operation takes precedence over XOR operation. For example, 4XOR6Power2=4(62)=436=32.
  • Consecutive powers are calculated from left to right. For example, 2Power3Power4=(23)4=84=4096.

Solution Click Below:- CLICK HERE

You are given an array B of length n and an integer k. The array A is given by Ai=2Bi and the expression E is given by E=A1A2A3An. You need to find the XOR of the values of all possible unambiguous expressions E which can be obtained from E and has at least k  symbols used as XOR operation. Since the answer can be very large, you need to find it modulo 2220. Since this number can also be very large, you need to print its binary representation without leading zeroes. If the answer is equal to 0, print 0.


Input

The first line of input contains two integers n and k (1n220,0k<n).

The second line of input contains n integers B1,B2,,Bn (1Bi<220).

Output

Print a single line containing a binary string without leading zeroes denoting the answer to the problem. If the answer is equal to 0, print 0.

Join Now for Solution:- 

                   

No comments:

Post a Comment