Skip to content

Commit

Permalink
Merge pull request #22 from Ankur-Dwivedi22/day3_sol
Browse files Browse the repository at this point in the history
chore: completed day_3 hard task
  • Loading branch information
sanghaibiraj authored Mar 24, 2024
2 parents 5407efc + 0c8f47b commit 03b74a9
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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}
64 changes: 63 additions & 1 deletion hard/day_3/solution.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,63 @@
//Write your code here
//Write your code here
// HARE RAM HARE KRISHNA

#include <bits/stdc++.h>
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);
}

0 comments on commit 03b74a9

Please sign in to comment.