0

Ninja and Bombs

Difficulty: EASY

Problem Statement
Suggest Edit

Ninja wants to travel from his house to his best friend’s house. The houses are located on a 2D coordinate plane, with Ninja’s house being situated at the origin. Ninja’s friend’s house is located somewhere on the x-axis. Now bombs are located at every point with an odd x-coordinate. Ninja can reach his friend’s house if it is an even coordinate else, he cannot reach there because there is a bomb placed at that point. There is a dragon who doesn’t let ninja use, modulus operator.

You are given an integer ‘N’ denoting the x-coordinate of Ninja’s friend’s house. Can Ninja reach his friend’s house? If yes, then return 1 else, return 0. Can you help him find without using the modulus operator?

Input Format:
The first line contains ‘T’, denoting the number of test cases.

Each test case contains a single integer ‘N’, denoting the x-coordinate of Ninja’s friend’s house.
Output Format:
For each test case, return '1' if Ninja can reach his friend’s house else return '0'.
Note:
You cannot make use of the modulus operation.
You are not required to print the expected output; it has already been taken care of. 
Just implement the function.
Constraints:
1 <= T <= 10
1 <= N <= 10^9

Time Limit: 1 sec  
Sample Input 1 :
2
2
1
Sample Output 1 :
1
0   
Explanation for Sample Input 1 :
In the first test case, the x-coordinate of his friend’s house is, even so, Ninja can reach so 1 is returned.
In the second test case, the x-coordinate of his friend’s house is, odd so, Ninja can reach so 0 is returned.
Sample Input 2 :
2
7
2
Sample Output 2 :
0
1
Reset Code
Full screen
copy-code
Console