Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell (0,0). Robot can perform the following four kinds of operations: U — move from (x,y) to (x,y+1); D — move
This way 题意: 给你一个长度为n的数组,你要修改其中的某些值使得任意的l,r, g c d ( a [ l ] , a [ l + 1 ] . . . a [ r ] ) = = r − l + 1 gcd(a[l],a[l+1]...a[r])==r-l+1 gcd(a[l],a[l+1]...a[r])==r−l+1的情况不存在。 对于所有的前缀都做一遍。 题解: 这道题…
3月25日-课堂笔记 前缀和预处理 O ( n ) \mathcal{O}(n) O(n) s[1] = a[1];for(int i = 2; i <= n; ++ i)s[i] = s[i - 1] + a[i]; 利用前缀和查询区间和 O ( 1 ) O(1) O(1) long long calc(int l, int r) {return l == 1 ? s[r] :