Maximum Number of Divisors
Time limit1sMemory limit256 MB
You answer each query with the largest divisor count among integers from 1 to N that are not multiples of P.
- Level
Easy3 of 10
- Topics
- Number theory, Prefix sum
- Solved
- No attempts yet
Problem
Mr. Strange dislikes the number , so you have to solve this problem for him.
Among the integers from to , keep only the ones that are not divisible by . Report the largest number of divisors any of the kept integers has.
Since , the number always survives, so the answer is at least .
Input
The first line contains the number of data sets ().
Each data set consists of three lines. The first line contains the number () that Mr. Strange dislikes. The second line contains the number of intervals (). The third line contains space separated integers (), where is the right end of the interval .
Output
Print one line per data set. Each line holds the answers for that data set in the order given, separated by single spaces. The -th value is the largest number of divisors among the integers in that are not divisible by .
Notes
With and the interval , no multiple of is at most . The numbers with the most divisors are (divisors ) and (divisors ), so the answer is . Over the number has divisors, which is the most.
With the numbers are forbidden. Over the maximum is now reached only by . Over no remaining number has divisors, so the answer is , reached by .