#P1850F. We Were Both Children
We Were Both Children
题面翻译
米哈依和斯拉夫有 只青蛙,每只青蛙初始都在 位置,每秒会往前跳 。你可以在位置 到 设置一个陷阱,陷阱会抓住经过它的所有青蛙,请问你最多可以抓住几只青蛙。
题目描述
Mihai and Slavic were looking at a group of frogs, numbered from to , all initially located at point . Frog has a hop length of .
Each second, frog hops units forward. Before any frogs start hopping, Slavic and Mihai can place exactly one trap in a coordinate in order to catch all frogs that will ever pass through the corresponding coordinate.
However, the children can't go far away from their home so they can only place a trap in the first points (that is, in a point with a coordinate between and ) and the children can't place a trap in point since they are scared of frogs.
Can you help Slavic and Mihai find out what is the maximum number of frogs they can catch using a trap?
输入格式
The first line of the input contains a single integer ( ) — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer ( ) — the number of frogs, which equals the distance Slavic and Mihai can travel to place a trap.
The second line of each test case contains integers ( ) — the lengths of the hops of the corresponding frogs.
It is guaranteed that the sum of over all test cases does not exceed .
输出格式
For each test case output a single integer — the maximum number of frogs Slavic and Mihai can catch using a trap.
样例 #1
样例输入 #1
7
5
1 2 3 4 5
3
2 2 2
6
3 1 3 4 9 10
9
1 3 2 4 2 3 7 8 5
1
10
8
7 11 6 8 12 4 4 8
10
9 11 9 12 1 7 2 5 8 10
样例输出 #1
3
3
3
5
0
4
4
提示
In the first test case, the frogs will hop as follows:
- Frog 1: $ 0 \to 1 \to 2 \to 3 \to \mathbf{\color{red}{4}} \to \cdots $
- Frog 2: $ 0 \to 2 \to \mathbf{\color{red}{4}} \to 6 \to 8 \to \cdots $
- Frog 3:
- Frog 4: $ 0 \to \mathbf{\color{red}{4}} \to 8 \to 12 \to 16 \to \cdots $
- Frog 5:
Therefore, if Slavic and Mihai put a trap at coordinate , they can catch three frogs: frogs 1, 2, and 4. It can be proven that they can't catch any more frogs.In the second test case, Slavic and Mihai can put a trap at coordinate and catch all three frogs instantly.
相关
在以下作业中: