Submit | All submissions | Best solutions | Back to list |
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 |
hide comments
|
|||||
2020-05-04 12:10:34
use formulae, use your mind not always the syntax |
|||||
2019-07-20 08:37:30
accepted in one go |
|||||
2019-04-25 21:11:51
Just find the sum of the square of the greater number and then subtract that from the square of smaller number - 1 Last edit: 2019-04-25 21:15:59 |
|||||
2019-02-27 15:16:16
test cases may misguide you, correct output for : 1 10 --- 385 7 10 --- 294 5 100 --- 338320 |
|||||
2018-11-18 07:25:47
This problem can be solved in O(1) time . |
|||||
2018-10-04 08:33:49
a, b as input iterate from a to b simple Last edit: 2018-10-04 08:34:50 |
|||||
2018-05-20 04:43:52
pintman: Not true, all input files contain exactly 2 space-separated numbers in a line. Got AC with a solution designed to crash if it was otherwise. Last edit: 2018-05-20 04:44:43 |
|||||
2018-05-19 08:49:30
It seems that input().split() (in python) results in three values for the first input but into two values for all others. Your input data may be not consistent. :( |
|||||
2018-03-23 16:56:13
AC in one go ! easy for a biginner :: |
|||||
2017-11-12 01:30:19
I hope this help ! http://mathforum.org/library/drmath/view/56920.html |