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;
}
相关推荐
落羽的落羽14 分钟前
【项目】JsonRpc框架——开发实现1(细节功能、字段定义、抽象层、具象层)
linux·服务器·网络·c++·人工智能·算法·机器学习
handler0135 分钟前
【算法】并查集(普通/扩展/带权)模板与例题
数据结构·c++·笔记·算法·c·图论·查并集
qq7422349841 小时前
从“感知”到“决断”:测评百度伐谋产业决策智能体的端到端推理与行动机制
人工智能·算法·百度·大模型·运筹优化
huohaiyu2 小时前
深入解析Java垃圾回收机制
java·开发语言·算法·gc
浮芷.2 小时前
鸿蒙PC端 TTS 并发调用问题详解:资源竞争与队列管理
算法·华为·开源·harmonyos·鸿蒙·鸿蒙系统
装不满的克莱因瓶2 小时前
掌握感知器的学习原理
人工智能·python·神经网络·算法·ai·卷积神经网络
Lsk_Smion2 小时前
力扣实训 _ [994].腐烂的橘子/图论
算法·leetcode·图论
轻微的风格艾丝凡2 小时前
两电平三相VSC整流模式从不控整流平滑切换至有源整流调试记录
算法·dsp·c2000
dongf20192 小时前
R语言KNN算法
算法·数据分析·r语言
小O的算法实验室3 小时前
2025年IEEE TASE,基于双层耦合平均场博弈的大规模智能体集成任务分配与轨迹规划
人工智能·算法·机器学习