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;
}
相关推荐
血色橄榄枝13 小时前
基于用户注册信息的关键词检测挑战赛「Datawhale AI 夏令营」
人工智能·算法·机器学习
c2385614 小时前
第二篇:《测试指挥官:可视化单题自测框架(含 assert 实操)》
java·数据库·c++·算法·安全性测试
六点_dn15 小时前
Linux学习笔记-printf命令
linux·运维·算法
遥感知识服务16 小时前
Sentinel-1 + DEM + FwDET + 随机森林:从快速水深初估到多因子误差修正
算法·随机森林·sentinel
来一碗刘肉面16 小时前
顺序表与链表的比较
数据结构·算法·链表
alphaTao16 小时前
LeetCode 每日一题 2026/7/13-2026/7/19
算法·leetcode
nnerddboy17 小时前
脑电信号处理实战 03 | 运动想象脑机接口入门:ERD/ERS、CSP 空间滤波与左右拳想象解码
算法·信号处理
QN1幻化引擎18 小时前
Dalin L — 我造了一门支持中文编程的语言,完整移植到 Rust 了
人工智能·算法·机器学习
Rainy Blue88318 小时前
C转C++速成
c语言·c++·算法
txzrxz18 小时前
二分图详解
数据结构·c++·算法·图论·深度优先搜索·二分图染色