diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2022-06-29 21:03:53 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2022-06-29 21:03:53 +0200 |
| commit | 37b7e815612dec5655d2ee2363835e2075701ae6 (patch) | |
| tree | 5c0b5e5fcf0c383c0e63c5c86524334630b35139 /codechef/XorAndMultiply | |
| parent | 1b8f7c9d4eb8b767d32dbbbfd96662b73c037627 (diff) | |
| download | competitive-programming-37b7e815612dec5655d2ee2363835e2075701ae6.tar.xz competitive-programming-37b7e815612dec5655d2ee2363835e2075701ae6.zip | |
Solved the first 6 problems of codechef Starters
Diffstat (limited to 'codechef/XorAndMultiply')
| -rw-r--r-- | codechef/XorAndMultiply/inp | 0 | ||||
| -rwxr-xr-x | codechef/XorAndMultiply/main | bin | 0 -> 43776 bytes | |||
| -rw-r--r-- | codechef/XorAndMultiply/main.cpp | 26 | ||||
| -rw-r--r-- | codechef/XorAndMultiply/main_input0.txt | 4 | ||||
| -rw-r--r-- | codechef/XorAndMultiply/main_output0.txt | 3 |
5 files changed, 33 insertions, 0 deletions
diff --git a/codechef/XorAndMultiply/inp b/codechef/XorAndMultiply/inp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/codechef/XorAndMultiply/inp diff --git a/codechef/XorAndMultiply/main b/codechef/XorAndMultiply/main Binary files differnew file mode 100755 index 0000000..a2063ee --- /dev/null +++ b/codechef/XorAndMultiply/main diff --git a/codechef/XorAndMultiply/main.cpp b/codechef/XorAndMultiply/main.cpp new file mode 100644 index 0000000..0d557ca --- /dev/null +++ b/codechef/XorAndMultiply/main.cpp @@ -0,0 +1,26 @@ +#include<bits/stdc++.h> + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while(tt--){ + int n = 0; + cin >> n; + long long a, b; + cin >> a >> b; + int mx = 0; + map<int, int> mp; + for(int i = 0; i < int(pow(2, n));i++) { + int l = a ^ i; + int r = b ^ i; + mx = max(mx, l * r); + cerr << mx << " " << i << endl; + mp[mx] = i; + } + cout << mp[mx] << endl; + } +} diff --git a/codechef/XorAndMultiply/main_input0.txt b/codechef/XorAndMultiply/main_input0.txt new file mode 100644 index 0000000..3726bfd --- /dev/null +++ b/codechef/XorAndMultiply/main_input0.txt @@ -0,0 +1,4 @@ +3 +1 0 0 +3 4 6 +2 2 1 diff --git a/codechef/XorAndMultiply/main_output0.txt b/codechef/XorAndMultiply/main_output0.txt new file mode 100644 index 0000000..983374a --- /dev/null +++ b/codechef/XorAndMultiply/main_output0.txt @@ -0,0 +1,3 @@ +1 +3 +0 |
