#P5435. 基于值域预处理的快速 GCD
基于值域预处理的快速 GCD
Description
Given positive integers , and another positive integers , you need to compute the greatest common divisor of and for every pair .
It is not hard to see that the output should contain positive integers. To reduce the impact of output on the program’s running efficiency, you only need to output lines, with one integer per line.
For , . Since the answer may be too large, you only need to output the result modulo .
Input Format
The first line contains one positive integer .
The second line contains positive integers, representing .
The third line contains positive integers, representing .
Output Format
Output lines. The -th line should contain one non-negative integer . Its meaning is described in the statement.
5
200 300 300 300 23333
666 666 666 666 123456
16
564
3636
14328
3905
Hint
For of the testdata, .
For of the testdata, $1\leqslant n\leqslant 5000;1\leqslant a_i,b_i\leqslant 10^6$.
Please pay attention to the impact of constant factors on the program’s running efficiency.
Translated by ChatGPT 5
京公网安备 11011102002149号