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;
}
相关推荐
UIU1146 分钟前
P1003 [NOIP 2011 提高组] 铺地毯
数据结构·c++·算法
爱读书的小胖10 分钟前
LeetCode 88. 合并两个有序数组 C 解题分析
c语言·数据结构·算法
垆边人似月.1 小时前
删边使每个连通块权值和为 target
算法·深度优先·图论
xxwl5851 小时前
区域赛算法模版第四章---数据结构
数据结构·c++·算法
xxwl5852 小时前
第六章---计算几何
笔记·学习·算法
Logic1013 小时前
C语言/数据结构二维数组题解:找出行列O个数均为偶数的格子——奇偶性预处理+二次遍历
c语言·数据结构·算法·二维数组·时间复杂度·动态内存分配·奇偶性
程序猿阿森3 小时前
【机器学习实战】朴素贝叶斯算法详解:从概率基础到商品评论情感分析
算法·机器学习·概率论
xxwl5853 小时前
区域赛算法模版第五章---数学与数论
c++·笔记·算法
看浪的路人4 小时前
第6讲:Agent 安全体系——Prompt 注入防御、工具调用审计与输出合规
人工智能·算法