1 #include <iostream>
2 using namespace std; 3
4 const int N = 1000;
5 int c[N]; 6
7 int logic(int x, int y) {
8 return (x & y) ^ ((x ^ y) | (~x & y));
9 }
10 void generate(int a, int b, int *c) {
11 for (int i = 0; i < b; i++) {
12 c[i] = logic(a, i) % (b + 1);
13 }
14 }
15 void recursion(int depth, int *arr, int size) {
16 if (depth <= 0 || size <= 1)return;
17 int pivot = arr[0];
18 int i = 0, j = size - 1;
19 while (i <= j) {
20 while (arr[i] < pivot)i++;
21 while (arr[j] > pivot)j--;
22 if (i <= j) {
23 int temp = arr[i];
24 arr[i] = arr[j];
25 arr[j] = temp;
26 i++;j--;
27 }
28 }
29 recursion(depth - 1, arr, j + 1);
30 recursion(depth - 1, arr + i, size - i);
31 } 32
33 int main() {
34 int a, b, d;
35 cin >> a >> b >> d;
36 generate(a, b, c);
37 recursion(d, c, b);
38 for (int i = 0; i < b; i++)cout << c[i] << " ";
39 }
0
0