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;
}
相关推荐
饮水桶_T1 小时前
C++ STL00 | 六大核心组件协作框架 笔记
开发语言·算法·百度·facebook·新浪微博
饮水桶_T4 小时前
Java调用大语言模型、多轮对话 笔记
笔记·算法·设计模式·电脑·ai编程
AAA修煤气灶刘哥4 小时前
QQ 音乐怎么在 25 毫秒内,决定一句话该交给谁?
人工智能·算法·llm
开开心心就好5 小时前
电脑禁止自动休眠工具,还能按负载定时
算法·智能手机·pdf·电脑·word·音视频·lua
geovindu17 小时前
python:DecisionTree
开发语言·后端·python·算法
geovindu18 小时前
python: Decision Tree Regressor
开发语言·后端·python·算法·决策树
AllData公司负责人21 小时前
实战二:AllData大模型与AI数据底座-数据传输平台-DBSyncer,搭建 Http 接口同步至 Doris,API 业务数据自动拉取入数仓
大数据·数据库·数据仓库·人工智能·算法·http·doris
武子康21 小时前
火系被选七成,就应该削弱吗?
人工智能·算法·机器学习
夜不会漫长1 天前
C++:C++11特性
开发语言·c++·算法