From 0c8f47b028d355adf3827aa3477d1b3d0059154f Mon Sep 17 00:00:00 2001 From: Ankur-Dwivedi22 Date: Sun, 24 Mar 2024 12:45:27 +0530 Subject: [PATCH] chore: completed day_3 hard task --- ....cpp_c2f6d70d8f6905b229d78483cfc14d83.prob | 1 + hard/day_3/solution.cpp | 64 ++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 hard/day_3/.cph/.solution.cpp_c2f6d70d8f6905b229d78483cfc14d83.prob diff --git a/hard/day_3/.cph/.solution.cpp_c2f6d70d8f6905b229d78483cfc14d83.prob b/hard/day_3/.cph/.solution.cpp_c2f6d70d8f6905b229d78483cfc14d83.prob new file mode 100644 index 0000000..cabc99d --- /dev/null +++ b/hard/day_3/.cph/.solution.cpp_c2f6d70d8f6905b229d78483cfc14d83.prob @@ -0,0 +1 @@ +{"name":"Local: solution","url":"d:\\OPCODE\\Code\\codecrack\\hard\\day_3\\solution.cpp","tests":[{"id":1711262363902,"input":"8\n2 10 5 12 9 5 1 5","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"d:\\OPCODE\\Code\\codecrack\\hard\\day_3\\solution.cpp","group":"local","local":true} \ No newline at end of file diff --git a/hard/day_3/solution.cpp b/hard/day_3/solution.cpp index 4f32122..02c415f 100644 --- a/hard/day_3/solution.cpp +++ b/hard/day_3/solution.cpp @@ -1 +1,63 @@ -//Write your code here \ No newline at end of file +//Write your code here +// HARE RAM HARE KRISHNA + +#include +using namespace std; +#define int long long +#define INF (int)1e18 +#define f first +#define s second +#define readyplayerone() \ + { \ + ios_base::sync_with_stdio(false); \ + cin.tie(0); \ + cout.tie(0); \ + } + +#define couty cout << "YES" << endl +#define coutn cout << "NO" << endl +#define cout(a) cout << a << endl + +#define min3(a, b, c) (a < b && a < c) ? a : (b < c) ? b \ + : c +#define max3(a, b, c) (a > b && a > c) ? a : (b > c) ? b \ + : c + +#define fi(i, s, e) for (int i = s; i < e; i++) +#define fd(i, s, e) for (int i = s; i > e; i--) + +#define ain(i, arr, n) \ + ; \ + for (int i = 0; i < n; i++) \ + { \ + cin >> arr[i]; \ + } +#define aout(i, arr, n) \ + ; \ + for (int i = 0; i < n; i++) \ + { \ + cout << arr[i] << "\t"; \ + } + +int solve(int x){ + int res = 0; + while(x){ + x >>= 1; + res += x; + } + return res; +} + +int32_t main(){ + int n, k, x, res=0; + cin>>n; + k = solve(n-1); + for(int i = 0; i < n; i++){ + cin>>x; + int a = solve(i); + int b = solve(n-i-1); + if(k - a - b == 0) + res ^= x; + } + cout(res); +} \ No newline at end of file