CF1616A.Integer Diversity
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given n integers a1,a2,…,an. You choose any subset of the given numbers (possibly, none or all numbers) and negate these numbers (i. e. change x→(−x)). What is the maximum number of different values in the array you can achieve?
给你 n 个整数 a1,a2,…,an。你可以任选其中一部分数(可以一个都不选,也可以全部选中),并将这些数取反(即令 x→(−x))。你最多能使数组中包含多少个不同的数值?
输入格式
The first line of input contains one integer t (1≤t≤100): the number of test cases.
The next lines contain the description of the t test cases, two lines per a test case.
In the first line you are given one integer n (1≤n≤100): the number of integers in the array.
The second line contains n integers a1,a2,…,an (−100≤ai≤100).
输入的第一行包含一个整数 t(1≤t≤100):测试用例的数量。
接下来的若干行描述 t 个测试用例,每个测试用例占两行。
第一行给出一个整数 n(1≤n≤100):数组中整数的个数。
第二行包含 n 个整数 a1,a2,…,an(−100≤ai≤100)。
输出格式
For each test case, print one integer: the maximum number of different elements in the array that you can achieve negating numbers in the array.
对于每个测试用例,输出一个整数:通过对数组中的数字取负,所能得到的数组中不同元素的最大个数。
输入输出样例
输入#1
3 4 1 1 2 2 3 1 2 3 2 0 0
输出#1
4 3 1
说明/提示
In the first example we can, for example, negate the first and the last numbers, achieving the array [−1,1,2,−2] with four different values.
In the second example all three numbers are already different.
In the third example negation does not change anything.
在第一个例子中,例如,我们可以将第一个数和最后一个数取相反数,从而得到数组 [−1,1,2,−2],其中包含四个不同的值。
在第二个例子中,所有三个数本身就已经互不相同。
在第三个例子中,取相反数不会改变任何数值。
输入解题思路,AI测评打分。不知道怎么写?