GCD of an Array(multiset或者线段树+数论)
题目
题目链接
You are given an array aa of length nn. You are asked to process qq queries of the following format: given integers i and x, multiply ai by x.
After processing each query you need to output the greatest common divisor (GCD) of all elements of the array a.
Since the answer can be too large, you are asked to output it modulo 10^9+7.
Input
The first line contains two integers — n and q (1≤n,q≤2⋅10^5).
The second line contains nn integers a1,a2,…,an (1≤ai≤2⋅10^5) — the elements of the array aa before the changes.
The next q lines contain queries in the following format: each line contains two integers i and x (1≤i≤n, 1≤x≤2⋅10^5).
Output
Print q lines: after processing each query output the GCD of all elements modulo 10^9+7 on a separate line.