Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin>>t;
while(t--){
ll n;
cin>>n;
ll arr[n];
for(ll i = 0; i < n; i++){
cin>>arr[i];
}
ll res = arr[0];
for(ll i = 1; i < n; i++){
res &= arr[i];
}
cout<<res<<endl;
}
}
Copy The Code &
Try With Live Editor
Input
4
2
1 2
3
1 1 3
4
3 11 3 7
5
11 7 15 3 7
2
1 2
3
1 1 3
4
3 11 3 7
5
11 7 15 3 7
Output
0
1
3
3
1
3
3
Demonstration
Codeforcess Solution 1559-A A. Mocha and Math ,C++, Java, Js and Python,1559-A,Codeforcess Solution