Submit | All submissions | Best solutions | Back to list |
PRADIPSUM - Easy Math |
Zoro is a student of a primary school. He likes to solve mathematical problem. One day he tries to solve a math, but he is unable to solve the problem efficiently because of being a student of primary school. As you are a programmer he wants your help to solve this problem. The problem is to find the sum of some consecutive numbers.
Example, if the first number is 2 and the last number is 5, then the result would be
2 + 3 + 4 + 5 = 14
Input
Every line contains two integers a and b. Input is terminated by the end of file.
Output
Output the sum the of all numbers between a and b (inclusively).
Constraints
-108 ≤ (a , b) ≤ 108
Example
Input: 2 5 5 10 Output: 14 45
Added by: | Nabil |
Date: | 2018-09-26 |
Time limit: | 2s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
hide comments
|
|||||
2018-10-08 14:51:53
@dewa251202 thanks lemme try that. edit: oh thanks alot learned something new at programming Last edit: 2018-10-08 15:02:52 |
|||||
2018-10-02 11:09:37
@erik_prasetio the easiest way is while(cin >> a >> b) |
|||||
2018-09-30 15:02:58
beware of a>b!! costed me 4 WA |
|||||
2018-09-30 14:34:56
Take care of negative numbers. And use, while(scanf("%lld%lld" ,&a, &b) != EOF) for input |
|||||
2018-09-30 12:24:28
How to make the "Input is terminated by (end of file)", I'm new at programming |
|||||
2018-09-30 04:27:21
What's wrong with my first submission? :( Edit : Nevermind, i didn't read the problem carefully Last edit: 2018-09-30 04:29:34 |
|||||
2018-09-29 16:58:41
Watch out for stupid a > b testcases. |