CF2200A.Eating Game

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

During their turn, if player ii has any dishes remaining, they must eat exactly one dish. Then, player (i mod n)+1(i \bmod n) + 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.

有 nn 名玩家围坐在一张圆桌旁进行游戏。第 ii 名玩家有 aia_i 道菜要吃。他们轮流进食,且任意一名玩家均可率先开始。

在自己的回合中,若第 ii 名玩家仍有剩余的菜,则必须恰好吃掉一道菜;随后,第 (i mod n)+1(i \bmod n) + 1 名玩家开始其回合。这一过程持续进行,直至所有菜均被吃完。

吃掉最后一道菜的玩家被视为获胜者。请确定可能成为获胜者的玩家人数。

输入格式

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

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

The second line of each test case contains nn integers, the elements of aa (1≤ai≤101 \leq a_i \leq 10).

第一行包含一个整数 tt(1≤t≤50001 \leq t \leq 5000),表示测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤101 \leq n \leq 10)。

每个测试用例的第二行包含 nn 个整数,即数组 aa 的元素(1≤ai≤101 \leq a_i \leq 10)。

输出格式

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

对于每个测试用例,输出一行答案。

输入输出样例

  • 输入#1

    3
    1
    10
    2
    6 7
    4
    1 4 3 4

    输出#1

    1
    1
    2

说明/提示

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

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

In the third test case, players 22 and 44 can win.

在第一个测试用例中,无论从哪位玩家开始,玩家 11 均获胜。

在第二个测试用例中,无论从哪位玩家开始,玩家 22 均获胜。

在第三个测试用例中,玩家 22 和玩家 44 可以获胜。

输入解题思路,AI测评打分。不知道怎么写?

首页