CF1392A.Omkar and Password

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Lord Omkar has permitted you to enter the Holy Church of Omkar! To test your worthiness, Omkar gives you a password which you must interpret!

A password is an array aa of nn positive integers. You apply the following operation to the array: pick any two adjacent numbers that are not equal to each other and replace them with their sum. Formally, choose an index ii such that 1i<n1 \leq i < n and aiai+1a_{i} \neq a_{i+1} , delete both aia_i and ai+1a_{i+1} from the array and put ai+ai+1a_{i}+a_{i+1} in their place.

For example, for array [7,4,3,7][7, 4, 3, 7] you can choose i=2i = 2 and the array will become [7,4+3,7]=[7,7,7][7, 4+3, 7] = [7, 7, 7] . Note that in this array you can't apply this operation anymore.

Notice that one operation will decrease the size of the password by 11 . What is the shortest possible length of the password after some number (possibly 00 ) of operations?

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt ( 1t1001 \le t \le 100 ). Description of the test cases follows.

The first line of each test case contains an integer nn ( 1n21051 \leq n \leq 2 \cdot 10^5 ) — the length of the password.

The second line of each test case contains nn integers a1,a2,,ana_{1},a_{2},\dots,a_{n} ( 1ai1091 \leq a_{i} \leq 10^9 ) — the initial contents of your password.

The sum of nn over all test cases will not exceed 21052 \cdot 10^5 .

输出格式

For each password, print one integer: the shortest possible length of the password after some number of operations.

输入输出样例

  • 输入#1

    2
    4
    2 1 3 1
    2
    420 420

    输出#1

    1
    2

说明/提示

In the first test case, you can do the following to achieve a length of 11 :

Pick i=2i=2 to get [2,4,1][2, 4, 1]

Pick i=1i=1 to get [6,1][6, 1]

Pick i=1i=1 to get [7][7]

In the second test case, you can't perform any operations because there is no valid ii that satisfies the requirements mentioned above.

首页