Problem descriptionthere is a special number sequence which has n + 1 integers. For each number in sequence, we have two rules:
● AI in [0, N]
● AI = AJ (I = J)
For sequence a and sequence B, the integrating Degree t is defined as follows ("writable" denotes exclusive or ):
T = (A0 rjb0) + (A1 rjb1) + · + (an 1_bn)
(Sequence B shoshould also satisfy the rules described abve)
Now give you a number N and the sequence A. You shoshould calculate the maximum integrating Degree t and print the sequence B.
Inputthere are multiple test cases. Please process till EOF.
For each case, the first line contains an integer N (1 ≤ n ≤ 105), the second line contains A0, A1, A2,...,.
Outputfor each case, output two lines. the first line contains the maximum integrating Degree t. the second line contains N + 1 integers B0, B1, B2 ,..., bn. there is exactly one space between Bi AND Bi + 1
(0 ≤ I ≤ n-1) . Don't ouput any spaces after bn.
Sample Input
42 0 1 4 3
Sample output
201 0 2 3 4 Question: Find the two [0, N] in the order of the maximum values of two or two differences or the sum: Calculate a regular question. For example, the maximum number that can be exclusive or reached is 111, so there are () and (), then we will push down the two solutions in turn, for example, the values of and 5 are, # include
# include
# include
# include
# include
typedef _ int64 ll; // typedef long ll; using namespace STD; const int maxn = 100005; ll ans [maxn]; int N; int CAL (INT m) {int Len = 0; while (m) {M >>= 1; Len ++;} return Len;} ll Init (INT m) {ll sum = 0; while (M> = 0) {int Len = CAL (m); LL max = (LL) (1
HDU-5014 Number Sequence