A. Candies for Nephews

time limit per test

1 second

memory limit per test

256 megabytes

Monocarp has three nephews. New Year is coming, and Monocarp has n candies that he will gift to his nephews.

To ensure that none of the nephews feels left out, Monokarp wants to give each of the three nephews the same number of candies.

Determine the minimum number of candies that Monocarp needs to buy additionally so that he can give each of the three nephews the same number of candies. Note that all n candies that Monocarp initially has will be given to the nephews.

Input

The first line contains an integer t (1≤t≤100) --- the number of test cases.

Each test case consists of one line containing one integer n (1≤n≤100) --- the number of candies that Monocarp initially has.

Output

For each test case, print one integer --- the minimum number of candies that Monocarp needs to buy additionally so that he can give each of the three nephews the same number of candies.

Example

Input

Copy

复制代码

2

7

24

Output

Copy

复制代码

2

0

Note

In the first example, Monocarp needs to buy 2 candies. After that, he will have 9 candies, and he can give each of the three nephews 3 candies.

In the second example, Monocarp does not need to buy any candies, as he initially has 24 candies, and he can give each of the three nephews 8 candies.

解题说明:水题,直接计算出差值即可。

cpp 复制代码
#include <stdio.h>
int main() 
{
	int t;
	scanf("%d", &t);
	while (t--) 
	{
		int n;
		scanf("%d", &n);
		if (n % 3 == 0)
		{
			printf("0\n");
		}
		else
		{
			printf("%d\n", 3 - n % 3);
		}
	}
	return 0;
}
相关推荐
To_OC4 小时前
LC 994 腐烂的橘子:人人都说是 BFS 入门题,我却写了三遍才过
javascript·算法·leetcode
金銀銅鐵8 小时前
[Python] 扩展欧几里得算法
python·数学·算法
To_OC10 小时前
LC 200 岛屿数量:经典 DFS 入门题,我第一次写居然连方向都搞错了
javascript·算法·leetcode
To_OC1 天前
LC 128 最长连续序列:别上来就排序,O (n) 解法才是这题的灵魂
javascript·算法·leetcode
05Kevin2 天前
lk每日冒险题--数据结构6.27
算法
To_OC2 天前
从一次栈溢出报错说起,我把递归彻底扒明白了
javascript·算法·程序员
千纸鹤安安2 天前
千问Qwen-AgentWorld来了:一个语言模型搞定七大Agent场景,GPT-5.4都输了
算法
七牛开发者2 天前
MCP 到底是什么?为什么 Agent 都想接上它
算法·aigc·agent