From 37b7e815612dec5655d2ee2363835e2075701ae6 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Wed, 29 Jun 2022 21:03:53 +0200 Subject: Solved the first 6 problems of codechef Starters --- codechef/XorAndMultiply/main.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 codechef/XorAndMultiply/main.cpp (limited to 'codechef/XorAndMultiply/main.cpp') 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 + +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 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; + } +} -- cgit v1.2.3