competitive-coding

How can we calculate weighted cumulative sum of squares with prefix range updates by one?

不问归期 提交于 2020-05-10 06:45:32
问题 Given an array A with n elements which starts with all 0 s and another array W also with n elements (all greater than 0 ), we want to perform the following operation repeatedly; For a given k, increment A[0], A[1], .... A[k] each by 1, and report the value of A[0]^2 * W[0] + A[1]^2 * W[1] + ... + A[n-1]^2 * W[n-1] . Looking for an O(log n) solution (per query), or faster. 来源: https://stackoverflow.com/questions/61122170/how-can-we-calculate-weighted-cumulative-sum-of-squares-with-prefix-range

How can we calculate weighted cumulative sum of squares with prefix range updates by one?

被刻印的时光 ゝ 提交于 2020-05-10 06:45:11
问题 Given an array A with n elements which starts with all 0 s and another array W also with n elements (all greater than 0 ), we want to perform the following operation repeatedly; For a given k, increment A[0], A[1], .... A[k] each by 1, and report the value of A[0]^2 * W[0] + A[1]^2 * W[1] + ... + A[n-1]^2 * W[n-1] . Looking for an O(log n) solution (per query), or faster. 来源: https://stackoverflow.com/questions/61122170/how-can-we-calculate-weighted-cumulative-sum-of-squares-with-prefix-range

Fill a partially filled matrix such that xor of 4 corner elements of all its sub matrices is 0 [closed]

牧云@^-^@ 提交于 2020-04-07 10:39:08
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 11 hours ago . The problem is: Given a matrix of dimensions N*M with only K cells filled. You are required to fill rest of the cells with values ranging from 0 to 2^30-1 such that: the xor of the 4 corner cell elements equals 0. (1) is satisfied by every sub-matrix of dimensions p*q where p>1