CF1764B.Doremy's Perfect Math Class

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

"Everybody! Doremy's Perfect Math Class is about to start! Come and do your best if you want to have as much IQ as me!" In today's math class, Doremy is teaching everyone subtraction. Now she gives you a quiz to prove that you are paying attention in class.

You are given a set SS containing positive integers. You may perform the following operation some (possibly zero) number of times:

  • choose two integers xx and yy from the set SS such that x>yx \gt y and x−yx - y is not in the set SS.
  • add x−yx-y into the set SS.

You need to tell Doremy the maximum possible number of integers in SS if the operations are performed optimally. It can be proven that this number is finite.

“大家好!多蕾米的完美数学课马上就要开始啦!想拥有和我一样高的智商,就快来大展身手吧!”
在今天的数学课上,多蕾米正在教大家减法。现在她出了一道小测验,来检验你是否认真听讲。

给你一个包含正整数的集合 SS。你可以执行以下操作若干次(可以为零次):

  • 从集合 SS 中选出两个整数 xx 和 yy,满足 x>yx \gt y,且 x−yx - y 不在集合 SS 中;
  • 将 x−yx-y 加入集合 SS。

你需要告诉多蕾米:若以最优方式执行上述操作,集合 SS 中最多可能包含多少个整数?可以证明该最大值是有限的。

输入格式

The input consists of multiple test cases. The first line contains a single integer tt (1≤t≤1041\le t\le 10^4) — the number of test cases. The description of the test cases follows.

The first line contains an integer nn (2≤n≤1052 \le n\le 10^5) — the size of the set SS.

The second line contains nn integers a1,a2,…,ana_1,a_2,\dots,a_n (1≤a1<a2<⋯<an≤1091\le a_1 \lt a_2 \lt \cdots \lt a_n \le 10^9) — the positive integers in SS.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052\cdot 10^5.

输入包含多个测试用例。第一行包含一个整数 tt(1≤t≤1041\le t\le 10^4),表示测试用例的数量。随后是各测试用例的描述。

第一行包含一个整数 nn(2≤n≤1052 \le n\le 10^5),表示集合 SS 的大小。

第二行包含 nn 个整数 a1,a2,…,ana_1,a_2,\dots,a_n(1≤a1<a2<⋯<an≤1091\le a_1 \lt a_2 \lt \cdots \lt a_n \le 10^9),即集合 SS 中的正整数。

保证所有测试用例的 nn 值之和不超过 2⋅1052\cdot 10^5。

输出格式

For each test case, you need to output the maximum possible number of integers in SS. It can be proven that this value is finite.

对于每个测试用例,你需要输出集合 SS 中可能包含的整数的最大数量。可以证明该值是有限的。

输入输出样例

  • 输入#1

    2
    2
    1 2
    3
    5 10 25

    输出#1

    2
    5

说明/提示

In the first test case, no such xx and yy exist. The maximum possible number of integers in SS is 22.

In the second test case,

  • S=5,10,25S={5,10,25} at first. You can choose x=25x=25, y=10y=10, then add x−y=15x-y=15 to the set.
  • S=5,10,15,25S={5,10,15,25} now. You can choose x=25x=25, y=5y=5, then add x−y=20x-y=20 to the set.
  • S=5,10,15,20,25S={5,10,15,20,25} now. You can not perform any operation now.

After performing all operations, the number of integers in SS is 55. It can be proven that no other sequence of operations allows SS to contain more than 55 integers.

在第一个测试用例中,不存在满足条件的 xx 和 yy。集合 SS 中整数的最大可能数量为 22。

在第二个测试用例中,

  • 初始时 S={5,10,25}S = \{5, 10, 25\}。你可以选择 x=25x = 25、y=10y = 10,然后将 x−y=15x - y = 15 加入集合。
  • 此时 S={5,10,15,25}S = \{5, 10, 15, 25\}。你可以选择 x=25x = 25、y=5y = 5,然后将 x−y=20x - y = 20 加入集合。
  • 此时 S={5,10,15,20,25}S = \{5, 10, 15, 20, 25\}。此时无法再执行任何操作。

执行完所有操作后,集合 SS 中的整数个数为 55。可以证明:不存在其他操作序列能使 SS 包含超过 55 个整数。

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

首页