Hi, I was solving [this](https://mirror.codeforces.com/contest/1790/problem/C) problem a few minutes ago, and the following problem is a subproblem of that one.↵
↵
Given integer $n$, $ n \ge 3$, and array $a$ consisting of $n - 1$ integers, all of them are equal to some value $b$. Later, some integer $c$, such that $c \ne b$ is selected and inserted into the array $a$ at random position. By given $n$ and $a$ find $c$.↵
↵
This problem itself isn't so difficult, but with a certain restriction I couldn't solve it. The restriction is folowing: you can't use $if$ and ternary operators in any way.↵
↵
I came up with the solution, that calls $if$ only one time.↵
↵
<spoiler summary="my solution">~~~~~↵
#include <bits/stdc++.h>↵
↵
using namespace std;↵
↵
int a[100001] = {0};↵
↵
int main()↵
{↵
ios_base::sync_with_stdio(false);↵
cin.tie(nullptr);↵
int n, ans = 0;↵
cin >> n;↵
for(int i = 0; i < n; i++)↵
cin >> a[i];↵
if(a[0] == a[1])↵
for(int i = (n & 1) ^ 1; i < n; i++)↵
ans ^= a[i];↵
else↵
for(int i = 0; i < 3; i++)↵
ans ^= a[i];↵
cout << ans << "\n";↵
return 0;↵
}↵
~~~~~↵
</spoiler>↵
↵
Can you solve this problem with the given restriction?↵
↵
Given integer $n$, $ n \ge 3$, and array $a$ consisting of $n - 1$ integers, all of them are equal to some value $b$. Later, some integer $c$, such that $c \ne b$ is selected and inserted into the array $a$ at random position. By given $n$ and $a$ find $c$.↵
↵
This problem itself isn't so difficult, but with a certain restriction I couldn't solve it. The restriction is folowing: you can't use $if$ and ternary operators in any way.↵
↵
I came up with the solution, that calls $if$ only one time.↵
↵
<spoiler summary="my solution">~~~~~↵
#include <bits/stdc++.h>↵
↵
using namespace std;↵
↵
int a[100001] = {0};↵
↵
int main()↵
{↵
ios_base::sync_with_stdio(false);↵
cin.tie(nullptr);↵
int n, ans = 0;↵
cin >> n;↵
for(int i = 0; i < n; i++)↵
cin >> a[i];↵
if(a[0] == a[1])↵
for(int i = (n & 1) ^ 1; i < n; i++)↵
ans ^= a[i];↵
else↵
for(int i = 0; i < 3; i++)↵
ans ^= a[i];↵
cout << ans << "\n";↵
return 0;↵
}↵
~~~~~↵
</spoiler>↵
↵
Can you solve this problem with the given restriction?↵