PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CCBCHBA0000051. Sum of Consecutive Odd Numbers II (Sum of Consecutive Odd Numbers II)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Sum of Consecutive Odd Numbers II (Sum of Consecutive Odd Numbers II)
Sum of Consecutive Odd Numbers II
Source: beecrowd
Version: Phuoc Hung OJ Extended
Problem Statement
Given t pairs x,y, print the sum of odd integers strictly between each pair, regardless of order. t belongs to the original input.
Input
1<=t<=100; each endpoint in [-1000,1000] (PHOJ Extended bound).
Output
t lines, each the sum of odd integers strictly between one pair.
Subtasks
- Subtask 1 (20%): t<=5, |x|,|y|<=10.
- Subtask 2 (30%): t<=30, |x|,|y|<=100.
- Subtask 3 (50%): t<=100, |x|,|y|<=1000.
Examples
Example 1
Input
3
6 9
-5 2
5 5
Output
7
-3
0
Explanation
(6,9) contains 7; (-5,2) contains -3,-1,1; equal endpoints give zero.
Example 2
Input
2
1 5
5 1
Output
3
3
Explanation
Both orders contain only the odd integer 3.