generated from OPCODE-Open-Spring-Fest/template
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from Ankur-Dwivedi22/day3_sol
chore: completed day_3 hard task
- Loading branch information
Showing
2 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
hard/day_3/.cph/.solution.cpp_c2f6d70d8f6905b229d78483cfc14d83.prob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |