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;
}
相关推荐
FPGA信号处理11 分钟前
【凸优化】第一节课(下):保凸运算、分离超平面与 Farkas 引理
人工智能·算法·机器学习
怕浪猫28 分钟前
Agent 的记忆系统怎么设计?面试官想听的是这个
算法·面试·github
C++ 老炮儿的技术栈31 分钟前
C++ const 的3个核心作用
服务器·c语言·c++·算法·c
有毒的教程44 分钟前
Dev-C++ 避免爆栈(Stack Overflow)完整方案
c++·算法·深度优先
在所不辞兄1 小时前
刚性问题误差容限设置技巧
深度学习·神经网络·算法·机器学习
啊啊啊啊啊!!!!1 小时前
unordered_map和unordered_set的使用
算法
java_nnnn1 小时前
LeetCode刷题双指针(快乐数+盛最多水的容器)Java
算法·leetcode·职场和发展
yi01110 小时前
LeetCode 219:存在重复元素 II——哈希表记录“最近一次出现的位置”
数据结构·人工智能·笔记·python·算法·leetcode·哈希表
灯澜忆梦13 小时前
【面向对象编程C++】| 基础语法
java·c++·算法
小蒋观天下13 小时前
专项方案:大场景港口AI安防、多干扰环境下的算法调优与落地实操
人工智能·深度学习·算法·安全·机器学习·计算机视觉·ai大模型