A15486 | Doremy's Perfect Math Class
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
"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 $S$ containing positive integers. You may perform the following operation some (possibly zero) number of times:
- choose two integers $x$ and $y$ from the set $S$ such that $x > y$ and $x - y$ is not in the set $S$ .
- add $x-y$ into the set $S$ .
You need to tell Doremy the maximum possible number of integers in $S$ if the operations are performed optimally. It can be proven that this number is finite.
You are given a set $S$ containing positive integers. You may perform the following operation some (possibly zero) number of times:
- choose two integers $x$ and $y$ from the set $S$ such that $x > y$ and $x - y$ is not in the set $S$ .
- add $x-y$ into the set $S$ .
You need to tell Doremy the maximum possible number of integers in $S$ if the operations are performed optimally. It can be proven that this number is finite.
输入格式
The input consists of multiple test cases. The first line contains a single integer $t$ ( $1\le t\le 10^4$ ) — the number of test cases. The description of the test cases follows.
The first line contains an integer $n$ ( $2 \le n\le 10^5$ ) — the size of the set $S$ .
The second line contains $n$ integers $a_1,a_2,\dots,a_n$ ( $1\le a_1 < a_2 < \cdots < a_n \le 10^9$ ) — the positive integers in $S$ .
It is guaranteed that the sum of $n$ over all test cases does not exceed $2\cdot 10^5$ .
The first line contains an integer $n$ ( $2 \le n\le 10^5$ ) — the size of the set $S$ .
The second line contains $n$ integers $a_1,a_2,\dots,a_n$ ( $1\le a_1 < a_2 < \cdots < a_n \le 10^9$ ) — the positive integers in $S$ .
It is guaranteed that the sum of $n$ over all test cases does not exceed $2\cdot 10^5$ .
输出格式
For each test case, you need to output the maximum possible number of integers in $S$ . It can be proven that this value is finite.
输入输出样例
输入 #1
2 2 1 2 3 5 10 25
输出 #1
2 5
In the first test case, no such $x$ and $y$ exist. The maximum possible number of integers in $S$ is $2$ .
In the second test case,
- $S=\{5,10,25\}$ at first. You can choose $x=25$ , $y=10$ , then add $x-y=15$ to the set.
- $S=\{5,10,15,25\}$ now. You can choose $x=25$ , $y=5$ , then add $x-y=20$ to the set.
- $S=\{5,10,15,20,25\}$ now. You can not perform any operation now.
After performing all operations, the number of integers in $S$ is $5$ . It can be proven that no other sequence of operations allows $S$ to contain more than $5$ integers.
In the second test case,
- $S=\{5,10,25\}$ at first. You can choose $x=25$ , $y=10$ , then add $x-y=15$ to the set.
- $S=\{5,10,15,25\}$ now. You can choose $x=25$ , $y=5$ , then add $x-y=20$ to the set.
- $S=\{5,10,15,20,25\}$ now. You can not perform any operation now.
After performing all operations, the number of integers in $S$ is $5$ . It can be proven that no other sequence of operations allows $S$ to contain more than $5$ integers.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted