-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdaptive Bitwise Encoding.cpp
More file actions
40 lines (34 loc) · 933 Bytes
/
Adaptive Bitwise Encoding.cpp
File metadata and controls
40 lines (34 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define inf 1000000000000
typedef long long ll;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
void computeBitwiseOperations() {
ll x, y, z;
cin >> x >> y >> z;
ll andResult = x & y;
ll orResult = x | y;
ll xorResult = x ^ y;
ll mask;
if (z & 1) {
mask = ((1 << (z % 5 + 2)) - 1);
} else {
mask = ((1 << (z % 10)) - 1);
}
cout << "AND: " << andResult << endl;
cout << "OR: " << orResult << endl;
cout << "XOR: " << xorResult << endl;
cout << "Generated Bitmask: " << mask << endl;
cout << "Masked AND: " << (mask & andResult) << endl;
cout << "Masked OR: " << (mask & orResult) << endl;
cout << "Masked XOR: " << (mask & xorResult) << endl;
}
int main() {
fast;
int t = 1;
while (t--) {
computeBitwiseOperations();
}
return 0;
}