A. Eating Game

time limit per test

1 second

memory limit per test

256 megabytes

There are n players playing a game at a circular table. The i-th player has ai dishes to eat. They take turns eating the food, and any player can go first.

During their turn, if player i has any dishes remaining, they must eat exactly one dish. Then, player (imodn)+1 starts their turn. This continues until all dishes are finished.

The player who eats the last dish is considered the winner. Determine the number of players that can possibly be winners.

Input

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

The first line of each test case contains an integer n (1≤n≤10).

The second line of each test case contains n integers, the elements of a (1≤ai≤10).

Output

For each test case, output a line with the answer.

Example

Input

Copy

复制代码

3

1

10

2

6 7

4

1 4 3 4

Output

Copy

复制代码

1

1

2

Note

In the first test case, player 1 wins for every starting player.

In the second test case, player 2 wins for every starting player.

In the third test case, players 2 and 4 can win.

解题说明:水题,其实只需要找出最大的数字,然后统计个数即可。

cpp 复制代码
#include<stdio.h>
int main() 
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		int i, n;
		scanf("%d", &n);
		int a[10];
		int max = 0, count = 0;
		for (i = 0; i < n; i++) 
		{
			scanf("%d", &a[i]);
			if (a[i] > max)
			{
				max = a[i];
			}
		}
		for (i = 0; i < n; i++) 
		{
			if (a[i] == max)
			{
				count++;
			}
		}
		printf("%d\n", count);
	}
	return 0;
}
相关推荐
青梅味猪大肠11 小时前
【操作系统-60】临近适应算法
java·linux·开发语言·嵌入式硬件·算法·操作系统
其实防守也摸鱼1 天前
个人学习 Pwn 思路:从基础到漏洞利用的进阶路径
大数据·前端·人工智能·chrome·算法·安全·网络安全
Nuanyt1 天前
LeetCode Hot 100 链表专题(五)· 2 题(Java)
java·算法·leetcode·链表
w_zero_one1 天前
递归算法(一)
java·开发语言·算法
风影同志783241 天前
20 个比特能装下多少行情?——实测拆解 Kronos 的 K 线分词器
算法
写的都是BUG1 天前
APK 里的钥匙,一直就放在门口:聊聊加固真正该做什么
前端·算法
地平线开发者1 天前
CLIP 的零样本分类:一组文本如何变成图像分类器?
算法
京东云开发者1 天前
从“会生成”到“能生产”:萤火虫 AIGC 平台的 AI Infra 实践
算法·aigc·产品
youshi66681 天前
PID——算法改进
算法