defAbs(n): return (n ^ (n >> 31)) - (n >> 31) defmax(a, b): return b & ((a - b) >> 31) | a & (~(a - b) >> 31) defmin(a, b): return a & ((a - b) >> 31) | b & (~(a - b) >> 31)
Rem and Mod
know it too late qwq
Divisions
Floored : quotient floored toward negative infinity, remainder same sign as the divisor Truncated : quotient truncated toward zero, remainder as the same sign as the dividend Euclidean : quotient truncated to keep the remainder positive
Examples
% : In python, the symbol % is actually a modulo, not a remainder. a = -5, b = 3 c = a / b = -1.67…
Rem
Round off the fractional part of c in the direction of 0, after which c = -1
Rem = a - b * c = -5 - (3 * (-1)) = -2
Mod
Round c to negative infinity, after which c = -2
Mod = a - b * c = -5 - 3 * (-2) = 1
Interval gcd
Wl,r=(r−l+1)×gcd(Al,Al+1,⋯,Ar)。
Find maxWl,r
Solution:
There are at most logN distinct gcd’s inside n numbers.
So enumerate i, find all the different gcd’s before i, and then gcd them separately with ai Note down each different gcd and the beginning of their position. Then traverse the gcd once to find the largest weight.