## Algorithm

Problem Name: beecrowd | 1866

# Bill

By Ricardo Martins, IFSULDEMINAS Brazil

Timelimit: 1

Two friends ask the attendant a snack bar propose a challenge , so that whoever hit him more , would not pay the bill. Then the following is proposed : Given the following sum below report the result , with the same number of terms : S = 1 - 1 + 1 - 1 + 1 - 1 + 1 - 1 ... Write a program that , given a number of terms, report the result of the sum above.

## Input

An integer C shall be informed , which is the amount of test cases. Each test case starts with an integer N ( 1 ≤ N ≤ 1000) , indicating the number of terms of the sum .

## Output

For each test case print a number S , which is the sum of N terms of expression.

 Input Sample Output Sample 3 11 7 18 1 1 0

## Code Examples

### #1 Code Example with C++ Programming

```Code - C++ Programming```

``````
#include <iostream>
using namespace std;

int main()
{
int n , a;
cin >> n;

for(int i = 0; i  <  n ; i++){
cin >> a;
if(a%2 == 0){
cout << 0 << endl;
}
else
cout << 1 << endl;
}

return 0;
}
``````
Copy The Code &

Input

cmd
3 11 7 18

Output

cmd
1 1 0

### #2 Code Example with Javascript Programming

```Code - Javascript Programming```

``````
var lines = input.split('\n');
const number = lines.shift();
let N = lines.shift();
let boolean = false;
let i = 0;
let S = 0;
while(i  <  number){
for(let j = 1; j <= N;j++){
if(boolean){
boolean = false;
S--
}
else{
S++
boolean = true;
}
}
boolean = false;
console.log(S);
S = 0;
N = lines.shift();
i++;
}
``````
Copy The Code &

Input

cmd
3 11 7 18

Output

cmd
1 1 0