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;
}
相关推荐
lucas_AI30 分钟前
ConfBench:大模型的「我很有把握」,到底能不能信?
人工智能·算法
oier_Asad.Chen1 小时前
【洛谷题解/AcWing题解/真题】洛谷P2330【SCOI2005】繁忙的都市(Kruskal算法的再探究))
c++·算法·贪心算法·图论·最小生成树·kruskal
青 春 记 忆3 小时前
LeetCode 53. 最大子数组和|Python 解法详解
python·算法·leetcode
豆瓣鸡4 小时前
算法日记 - Day10
算法
戴西软件4 小时前
戴西CAxWorks.VPG车辆工程仿真软件技术解析(上)——安全仿真体系的自动化构建
运维·网络·数据库·人工智能·算法·安全·自动化
zander2584 小时前
4. 寻找两个正序数组的中位数:用分割点代替合并
数据结构·算法
Kisorge4 小时前
【电机控制器】 基于STSPIN32G4的FOC控制
stm32·嵌入式硬件·算法
Elivs4 小时前
RMSNorm函数
人工智能·算法·机器学习
tudousisi2225 小时前
P4447 [AHOI2018初中组] 分组 题解复盘
算法
SNAKEpc121385 小时前
OpenGL(十一)- 变换管线
c语言·c++·算法·矩阵·图形渲染