Олимпиадный тренинг

Задача 38468. Even odd


Задача

Темы: Вывод формулы
Masha loves even numbers, and Misha – odd. Therefore, they are always happy if they meet numbers they like.
Today they met all integers from A to B inclusive. Masha decided to calculate the sum of all even numbers from A to B, and Misha – the sum of all the odd ones, after which they began to argue who got the sum more. Help them – find the difference
between Masha's sum and Misha's sum.
The program receives as input two positive integers A and B, not exceeding 2×109.
The program should output a single number – the difference between the sum of even numbers and the sum of odd numbers from A to B.
Examples
# Input Output Explanation
1 3
6
2 The sum of even numbers is 4 + 6 = 10, the sum of odd numbers
is 3 + 5 = 8, the difference is 2.
2 3
7
-5 The sum of even numbers is 4 + 6 = 10, the sum of odd numbers
is 3 + 5 + 7 = 15, the difference is −5.