CF1728A.Colored Balls: Revisited

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

The title is a reference to the very first Educational Round from our writers team, Educational Round 18.

There is a bag, containing colored balls. There are nn different colors of balls, numbered from 11 to nn. There are cnti\mathit{cnt}_i balls of color ii in the bag. The total amount of balls in the bag is odd (e. g. cnt1+cnt2+⋯+cntn\mathit{cnt}_1 + \mathit{cnt}_2 + \dots + \mathit{cnt}_n is odd).

In one move, you can choose two balls with different colors and take them out of the bag.

At some point, all the remaining balls in the bag will have the same color. That's when you can't make moves anymore.

Find any possible color of the remaining balls.

标题是对我们的出题团队所举办的首场教育赛——教育赛 18 的致敬。

有一个装有彩色球的袋子。袋中球共有 nn 种不同颜色,编号为 11 到 nn。颜色为 ii 的球有 cnti\mathit{cnt}_i 个。袋中球的总数为奇数(即 cnt1+cnt2+⋯+cntn\mathit{cnt}_1 + \mathit{cnt}_2 + \dots + \mathit{cnt}_n 是奇数)。

每次操作,你可以选择两个颜色不同的球,并将它们从袋中取出。

在某一时刻,袋中剩余的所有球将具有同一种颜色,此时便无法再进行任何操作。

请找出袋中剩余球可能的一种颜色。

输入格式

The first line contains a single integer tt (1≤t≤10001 \le t \le 1000) — the number of testcases.

The first line of each testcase contains a single integer nn (1≤n≤201 \le n \le 20) — the number of colors.

The second line contains nn integers cnt1,cnt2,…,cntn\mathit{cnt}_1, \mathit{cnt}_2, \dots, \mathit{cnt}_n (1≤cnti≤1001 \le \mathit{cnt}_i \le 100) — the amount of balls of each color in the bag.

The total amount of balls in the bag is odd (e. g. cnt1+cnt2+⋯+cntn\mathit{cnt}_1 + \mathit{cnt}_2 + \dots + \mathit{cnt}_n is odd).

第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1≤n≤201 \le n \le 20)—— 颜色的种类数。

每个测试用例的第二行包含 nn 个整数 cnt1,cnt2,…,cntn\mathit{cnt}_1, \mathit{cnt}_2, \dots, \mathit{cnt}_n(1≤cnti≤1001 \le \mathit{cnt}_i \le 100)—— 袋中每种颜色小球的数量。

袋中小球的总数为奇数(即 cnt1+cnt2+⋯+cntn\mathit{cnt}_1 + \mathit{cnt}_2 + \dots + \mathit{cnt}_n 为奇数)。

输出格式

For each testcase, print a single integer — any possible color of the remaining balls, after you made some moves and can't make moves anymore.

对于每个测试用例,输出一个整数——在进行若干次操作且无法继续操作后,剩余小球的任意一种可能颜色。

输入输出样例

  • 输入#1

    3
    3
    1 1 1
    1
    9
    2
    4 7

    输出#1

    3
    1
    2

说明/提示

In the first testcase, your first and only move can be one of the following:

  • take balls with colors 11 and 22;
  • take balls with colors 11 and 33;
  • take balls with colors 22 and 33.

After the move, exactly one ball will remain. Its color can be 3,23, 2 or 11 depending on the move.

In the second testcase, you can't make moves at all — there is only color of balls already. This color is 11.

In the third testcase, you can keep removing one ball of color 11 and one ball of color 22 until there are no more balls of color 11. At the end, three balls of color 22 remain.

在第一个测试用例中,你的第一次(也是唯一一次)操作可以是以下之一:

  • 取出颜色为 11 和 22 的球;
  • 取出颜色为 11 和 33 的球;
  • 取出颜色为 22 和 33 的球。

操作之后,将恰好剩余一个球。其颜色取决于所选操作,可能为 33、22 或 11。

在第二个测试用例中,你根本无法进行任何操作——球只有一种颜色,该颜色为 11。

在第三个测试用例中,你可以不断取出一个颜色为 11 的球和一个颜色为 22 的球,直到颜色为 11 的球全部取完。最终,将剩余三个颜色为 22 的球。

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

首页