Problem Description Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14. Input The first line of the input contains…
题意 给定一个长度为N的数列A,以及M条指令 (N≤5* 10^5, M<=10^5),每条指令可能是以下两种之一: "C l r d",表示把 A[l],A[l+1],-,A[r] 都加上 d. "Q l r",表示询问 A[l],A[l+1],-,A[r] 的最大公约数(GCD). 由<九章算术>中的更相减损我们知道gcd(x,y)=gcd(x,y-x)同理可以推到多个整数.(可以用数学归纳法证明) 因此,构造一个长度为N的新数列B,其中B[i…
gcd Little White learned the greatest common divisor, so she plan to solve a problem: given \(x, n,\) query \(\sum_{a=1}^n\sum_{b=1}^ngcd(x^a−1,x^b−1)\) Input The first line of input is an integer T ( 1≤T≤300) For each test case ,the single line cont…