#SDNU1310. Cover Interval
Cover Interval
Description
On the math class, Teacher Young want to know some of students’ ability of programming, so he write a simple problem on the blackboard:
“There are several integer intervals [a , b] on the x-axis, and a is smaller than b, please compute the total length covered by these intervals.
Format
Input
The input has multiple test cases. Each case begins with a line contains one integer , which is the number of the intervals. Then comes lines, each line has two integers, and (separated by a space,), which are the left edge and right edge of the interval.
Output
For each test cases, output one Integer representing the total length.
Samples
3
2 5
1 4
7 8
5