CF1493D.GCD of an Array
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a of length n . You are asked to process q 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 109+7 .
输入格式
The first line contains two integers — n and q ( 1≤n,q≤2⋅105 ).
The second line contains n integers a1,a2,…,an ( 1≤ai≤2⋅105 ) — the elements of the array a 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⋅105 ).
输出格式
Print q lines: after processing each query output the GCD of all elements modulo 109+7 on a separate line.
输入输出样例
输入#1
4 3 1 6 8 12 1 12 2 3 3 3
输出#1
2 2 6
说明/提示
After the first query the array is [12,6,8,12] , gcd(12,6,8,12)=2 .
After the second query — [12,18,8,12] , gcd(12,18,8,12)=2 .
After the third query — [12,18,24,12] , gcd(12,18,24,12)=6 .
Here the gcd function denotes the greatest common divisor.