CF1850F.We Were Both Children
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Mihai and Slavic were looking at a group of n frogs, numbered from 1 to n , all initially located at point 0 . Frog i has a hop length of ai .
Each second, frog i hops ai 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 n points (that is, in a point with a coordinate between 1 and n ) and the children can't place a trap in point 0 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 t ( 1≤t≤100 ) — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer n ( 1≤n≤2⋅105 ) — 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 n integers a1,…,an ( 1≤ai≤109 ) — the lengths of the hops of the corresponding frogs.
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105 .
输出格式
For each test case output a single integer — the maximum number of frogs Slavic and Mihai can catch using a trap.
输入输出样例
输入#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→1→2→3→4→⋯
- Frog 2: 0→2→4→6→8→⋯
- Frog 3: 0→3→6→9→12→⋯
- Frog 4: 0→4→8→12→16→⋯
- Frog 5: 0→5→10→15→20→⋯
Therefore, if Slavic and Mihai put a trap at coordinate 4 , 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 2 and catch all three frogs instantly.