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;
}
相关推荐
倒头就睡的小比特4 天前
算法竞赛C++常用的STL
c++·算法
小羊没烦恼!4 天前
初探性能优化——2个月到4小时的性能提升
java·开发语言·windows·算法·c#
猎头南楼4 天前
知识社区推荐系统实践:新用户冷启动与长短期兴趣建模的挑战 资深推荐算法工程师
人工智能·深度学习·算法·机器学习
旖旎夜光4 天前
力控面试题 01.01: 判定字符是否唯一(位运算) —— 题解
c++·学习·算法·leetcode·力控
wzdark4 天前
大规模并行计算中的负载均衡算法研究4
算法
Because_of_Her14 天前
并查集-听课笔记
笔记·算法·并查集
码流子4 天前
高速公路安全监测实践:碰撞监测预警+物联网底座,从感知到处置的闭环
大数据·人工智能·物联网·算法·架构
another heaven4 天前
【算法/C++ MD5算法能否逆解码?原理、C++实现与同类哈希算法对比】
c++·算法·哈希算法
wzdark4 天前
从算法设计模式看编程思维的抽象能力4
算法
2601_962218614 天前
万象生鲜系统称重自动多退少补算法解决生鲜非标品痛点
大数据·数据库·人工智能·python·算法