CF1673E.Power or XOR?
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The symbol ∧ is quite ambiguous, especially when used without context. Sometimes it is used to denote a power ( a∧b=ab ) and sometimes it is used to denote the XOR operation ( a∧b=a⊕b ).
You have an ambiguous expression E=A1∧A2∧A3∧…∧An . 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)=4⊕36=32 .
- Consecutive powers are calculated from left to right. For example, 2Power3Power4=(23)4=84=4096 .
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=A1∧A2∧A3∧…∧An . 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 .
输入格式
The first line of input contains two integers n and k (1≤n≤220,0≤k<n) .
The second line of input contains n integers B1,B2,…,Bn (1≤Bi<220) .
输出格式
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 .
输入输出样例
输入#1
3 2 3 1 2
输出#1
1110
输入#2
3 1 3 1 2
输出#2
1010010
输入#3
3 0 3 1 2
输出#3
1000000000000000001010010
输入#4
2 1 1 1
输出#4
0
说明/提示
For each of the testcases 1 to 3 , A={23,21,22}={8,2,4} and E=8∧2∧4 .
For the first testcase, there is only one possible valid unambiguous expression E′=8⊕2⊕4=14=(1110)2 .
For the second testcase, there are three possible valid unambiguous expressions E′ :
- 8⊕2⊕4=14
- 82⊕4=64⊕4=68
- 8⊕24=8⊕16=24
XOR of the values of all of these is 14⊕68⊕24=82=(1010010)2 .For the third testcase, there are four possible valid unambiguous expressions E′ :
- 8⊕2⊕4=14
- 82⊕4=64⊕4=68
- 8⊕24=8⊕16=24
- (82)4=644=224=16777216
XOR of the values of all of these is 14⊕68⊕24⊕16777216=16777298=(1000000000000000001010010)2 .For the fourth testcase, A={2,2} and E=2∧2 . The only possible valid unambiguous expression E′=2⊕2=0=(0)2 .