# JBINARY - EDITORIAL

Contest

Setter: debrc

Tester: dustu_947 , mishra_roshan

Editorialist: debrc

Cakewalk

# PREREQUISITES:

Basic observations.

# PROBLEM:

Given a number N, determine if it’s binary representation ends with 1 or 0.

# EXPLANATION

Binary representation of a even number always ends with 0 whereas of a odd number always ends with 1. You just have to check if the number is odd or even.
If even - Jon likes the number so print 1, otherwise print 0.

# TIME COMPLEXITY

Time complexity is O(1) to check if the number is even or odd.

# SOLUTIONS:

Setter's Solution
C++
``````#include <iostream>
using namespace std;

int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
if (n%2==1){
cout<<"0"<<endl;
}
else cout<<"1"<<endl;
}
return 0;
}
``````
Python
``````for i in range (int(input())):
n = int(input())
if n%2==0:
print ("1")
else:
print("0")

``````
Tester's Solution
``````#include <iostream>
using namespace std;

int main() {
int T;
std::cin >> T;
while(T--)
{
int Num;
cin>>Num;
int bin;
Num=Num%2;
if(Num==1)
std::cout << 0 << std::endl;
else
std::cout << 1 << std::endl;
}
return 0;
}
``````

# ALTERNATIVE EXPLANATION

Bitwise And with a number will always give 0 if that number is even and 1 if number is odd.

Feel free to Share your approach.
Suggestions are welcomed as always had been.