#OLD56. Margarite and the best present
Margarite and the best present
Description
Littlegirl Margarita is a big fan of competitive programming. Sheespecially loves problems about arrays and queries on them.
Recently,she was presented with an array a of the sizeof 1000000000 elements that isfilled as follows:
a1=−1
a2=2
a3=−3
a4=4
a5=−5
Andso on ...
Thatis, the value of the i-th element of the array a iscalculated using the formula ai=i⋅(−1)^i.
Sheimmediately came up with q queries on this array. Eachquery is described with two numbers: ll and r. Theanswer to a query is the sum of all the elements of the array atpositions from ll to r inclusive.
Margaritareally wants to know the answer to each of the requests. She doesn'twant to count all this manually, but unfortunately, she couldn'twrite the program that solves the problem either. She has turned toyou — the best programmer.
Helpher find the answers!
Format
Input
Thefirst line contains a single integer q (1≤q≤1000) —the number of the queries.
Eachof the next q lines contains twointegers l and r (1≤l≤r≤100000000) —the descriptions of the queries.
Output
Print q lines,each containing one number — the answer to the query.
Samples
5
1 3
2 5
5 5
4 4
2 3
-2
-2
-5
4
-1