Hi all Is there a formula to find the sum of the following series
i<=j
i*j+(i-1)*(j-1)+...+(i-i)*(j-i)
thank you all
# | User | Rating |
---|---|---|
1 | tourist | 3845 |
2 | jiangly | 3707 |
3 | Benq | 3630 |
4 | orzdevinwang | 3573 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | jqdai0815 | 3532 |
8 | ecnerwala | 3501 |
9 | gyh20 | 3447 |
10 | Rebelz | 3409 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 171 |
2 | adamant | 163 |
3 | awoo | 162 |
4 | nor | 151 |
4 | maroonrk | 151 |
4 | -is-this-fft- | 151 |
7 | TheScrasse | 148 |
8 | atcoder_official | 146 |
9 | Petr | 145 |
10 | pajenegod | 144 |
Name |
---|
($ i*j + (i-1)*(j-1) + (i-2)*(j-2) + ... + (i-i)*(j-i)))
= i*j + i*j-i-j+1 + i*j-2*i-2*j+4 + ... + i*j-i*i-i*j+i*i
= i*j*(i+1) + (1+2+...+i)*(i+j) + 1^2+2^2+...+i^2
= i*j*(i+1) + i*(i+1)*(i+j)/2 + i*(i+1)*(2*i+1)/6
PS: Why TEX markup didn't work?
i am get it thank you there are mistake in your formula this is true : i * i * j — (i + j) * (i — 1) * i / 2 + (i — 1) * (i)* (2*(i — 1) + 1) / 6
i don't know about tex markup
may be this
i*(i+1)*(2i+1)/6 + (i*(i+1ll)/2ll) * (j-i)
thank you :D
Yes, there is. I take it you're trying to solve problem D from last contest, because this is exactly the formula for that one. Consider i ≤ j (the other case is analogous), then you can transform the expression into...
(i2 + i * (j - i)) + ((i - 1)2 + (i - 1) * (j - i)) + ... + (22 + 2 * (j - i)) + (12 + 1 * (j - i))
That's the sum of squares plus the sum of numbers multiplied by j - i, so we can express it as...
thank you for explanation :D
why is votes down :/ ?