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;
}
相关推荐
血小板要健康2 小时前
队列 + 宽搜(BFS):二叉树层序遍历 算法总结
java·数据结构·笔记·算法·leetcode·宽度优先
Felven2 小时前
A. Riptide
算法·c 算法
m0_739312872 小时前
四元数、李群SO(3)/李代数so(3)的作用及应用场景
算法·机器人·自动驾驶
artificiali2 小时前
880 第4章多元
人工智能·算法
Felven3 小时前
B. Deja Vu
数据结构·算法
小玮看世界3 小时前
[Python]螺旋遍历 vs 最短路径:方向控制类算法的“同源异流”
开发语言·python·算法
月华路3 小时前
《模型不玄学》第14章 标签、损失与样本权重
人工智能·算法·机器学习
黄金龙PLUS3 小时前
SPARKLE置换算法的优缺点
算法·网络安全·密码学·哈希算法·同态加密
不会就选b3 小时前
算法日常・每日刷题--<贪心>3
数据结构·算法·leetcode