Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Let C = 99^2 and A = {a_i,j where 0<i<99, 0<j<99} and assume that each element
- in A is labeled A_n where 0<n<C. The same goes for b and B.
- The sum that you are asking for, let's call it S, can be written as
- S = (A_0 - B_0) + (A_0 - B_1) + ... + (A_0 - B_C) +
- (A_1 - B_0) + ... + (A_1 - B_C) +
- ...
- (A_C - B_0) + ... + (A_C - B_C)
- A_0 occurs C times in the first row and the B terms can be written
- as -(B_0 + B_1 + ... + B_C), i.e.:
- C*A_0 - (B_0 + B_1 + ... + B_C)
- The sum B_0 + B_1 + ... + B_C is of course the sum of all elements in B. Let's
- call this S_B, and the sum of all elements in A S_A. The first row can be
- written as:
- C*A_0 - S_B
- The second row has exactly the same B terms but has A_1 instead of A_0, so:
- C*A_1 - S_B
- Now we can write S like:
- S = C*A_0 - S_B +
- C*A_1 - S_B +
- ...
- C*A_C - S_B
- The sum of the A terms in S can be written as C*(A_0 + A_1 + ... + A_C) and S_B
- occurs C times as well, so we end up with:
- S = C*S_A - C*S_B
- = C(S_A - S_B)
- = 99^2 * ((A_0 + A_1 + ... + A_C) - (B_0 + B_1 + ... + B_C))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement