GCD Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2742 Accepted Submission(s): 980 Problem Description Give you a sequence of N(N≤100,000) integers : a1,...,an(0<ai≤1000,000,000). There ar…
题目大意:给定一行n个正整数a[1]..a[n].m次询问,每次询问给定一个区间[L,R],输出a[L]..a[R]的最大公因数. 因为gcd满足交换律和结合律,所以用线段树维护区间上的gcd值即可. #include <cstdio> #include <cstring> using namespace std; const int MAX_RANGE = 1010; int GetGcd(int a, int b) { return b ? GetGcd(b, a % b) :…