A. CME

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Let's denote correct match equation (we will denote it as CME) an equation a+b=ca+b=c there all integers aa, bb and cc are greater than zero.

For example, equations 2+2=42+2=4 (||+||=||||) and 1+2=31+2=3 (|+||=|||) are CME but equations 1+2=41+2=4 (|+||=||||), 2+2=32+2=3 (||+||=|||), and 0+1=10+1=1 (+|=|) are not.

Now, you have nn matches. You want to assemble a CME using all your matches. Unfortunately, it is possible that you can't assemble the CME using all matches. But you can buy some extra matches and then assemble CME!

For example, if n=2n=2, you can buy two matches and assemble |+|=||, and if n=5n=5 you can buy one match and assemble ||+|=|||.

 

Calculate the minimum number of matches which you have to buy for assembling CME.

Note, that you have to answer qq independent queries.

Input

The first line contains one integer qq (1≤q≤1001≤q≤100) — the number of queries.

The only line of each query contains one integer nn (2≤n≤1092≤n≤109) — the number of matches.

Output

For each test case print one integer in single line — the minimum number of matches which you have to buy for assembling CME.

Example

input

Copy

4
2
5
8
11

output

Copy

2
1
0
1

Note

The first and second queries are explained in the statement.

In the third query, you can assemble 1+3=41+3=4 (|+|||=||||) without buying matches.

In the fourth query, buy one match and assemble 2+4=62+4=6 (||+||||=||||||).

解题说明:水题,很显然只要n为大于2的偶数一定可以找到1+n/2-1=n/2,如果n为奇数只需要多1个即可。当n为2的情况下需要实现1+1=2,多2个即可。

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
	int n;
	scanf("%d", &n);
	while (n--)
	{
		int s;
		scanf("%d", &s);
		if (s == 2)
		{
			printf("2\n");
		}
		else if (s % 2 == 0)
		{
			printf("0\n");
		}
		else
		{
			printf("1\n");
		}
	}
	return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值