Sequence and Queries HY
InterviewTime limit2sMemory limit1024 MB
Given a sequence A of length N, answer each query m by printing the minimum and maximum of the remainders A_i mod m, with m up to 300000.
- Level
Medium5 of 10
- Topics
- Array, Math, Number theory
- Solved
- No attempts yet
Problem
Given a sequence , , , of length , write a program that processes the following query.
- : Print the minimum and maximum values among , , , .
Input
The first line contains and , the length of the sequence and the number of queries, separated by a space.
The second line contains integers , , , separated by spaces.
From the third line, lines follow, each containing one query described above.
Output
For each query, print the minimum and maximum values, separated by a space, on its own line.