Public submissions
Source code of every submission to this problem in this contest will be visible for everyone since 2013-08-26 12:38:07.

SMPSUM - Iterated sums

Please compute the sum of squares for the given numbers: a, a+1, ..., b-1, b.

Input

Two numbers: a and b separated by space, where 1 <= a <= b <=100.

Output

Computed sum: a*a + (a+1)*(a+1) + ... + (b-1)*(b-1) + b*b

Example

Input:
1 4

Output:
30

Example 2

Input:
5 6

Output:
61

Added by:kuszi
Date:2013-08-26
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Public source code since: 2013-08-26 12:38:07

hide comments
2015-06-22 05:05:15
very easy :D AC in 1st go :D
2015-03-29 01:26:17 kuszi
@rixx 25+36=61, what is wrong here?
2015-03-27 20:33:12 rixx
first example is ok but what is the second example calculation ??
2015-01-25 13:10:46 Priyam-the-great
Very easy... Accepted in first go :D
2014-10-25 21:56:58 kuszi
@Amit Tapas
1 4
1*1 + 2*2 + 3*3 + 4*4 = 30
2014-10-24 13:29:30 Amit Tapas
the examples given are not clear.Pls explain the sum
2014-08-30 17:09:45 kuszi
@Adela Gao please name your main class "Main". There is a java corner at SPOJ forum.
2014-08-29 22:16:27 Adela Gao
My java file is working perfectly locally but it's impossible to compile online here
2014-01-16 22:56:09 kuszi
@Dennis Lee: Thank you!
2014-01-16 19:47:26 Dennis Lee
typo: squeres->squares
grammar: SVA Compute the sum of squeres for a given numbers: a, a+1, ..., b-1, b -> Compute the sum of squares for the given numbers: a, a+1, ..., b-1, b
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.