# MINOPER-Editorial

PRACTICE
Editorialist: Avishake Maji

EASY

Number Theory

# PROBLEM:

You are given a number X. You have to make this number divisible by 2. The operations you can perform is as follows:
⦁ Substract 1 from X
You can perform these operations zero or more no of times. You have to find the minimum number of operations required to make X divisible by 2.

### Input:

t: Number of test cases
X: the given number

### Output:

The minimum number of operations required to make X divisible by 2

1<=t<=1000
0<=X<=10^9

### Sample Input:

2
4
0

###Sample Output:

0
0

### Explanation:

Since 4 is divisible by 2 so the number of operation will be 0

Since 0 is divisible by 2 so the number of operation will be 0

# EXPLANATION:

According to the question we are told to find the minimum of operations required to make a number by 2 using the given operations( either add the number by 1 or substract 1 from the number). If the number is already even i.e divisible by 2 then the minimum no of operations will be 0. If the odd then we can easily convert it to even either by adding 1 or substracting 1 from the number. So the minimum number of operations will be 1. So all we need to find is whether the number is even or odd and print 0 or 1 respectively.

# SOLUTION:

``````#include <iostream>
#include<ctime>
#include<map>
#define ll long long int
using namespace std;
void solve();
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int t;
cin >> t;
while (t--) {
solve();
// cout << "\n";
}

return 0;
}
void solve()
{
ll n;
cin>>n;
if(n&1)
cout<<"1";
else
cout<<"0";
cout<<endl;
}``````