407061: GYM102697 032 Prison Break
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
032. Prison Breaktime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
Unfortunately, you have been sent to prison because you solved too many problems at CodeQuest 2021. Now, you're trying to break out. Your cell has a combination lock with $$$n$$$ dials. You're planning to try all of the possible combinations of the lock, and you want to know how many possible combinations the lock has.
InputThe first line of input contains a positive integer $$$n$$$: the number of dials on the lock. The next $$$n$$$ lines each contain two space-separated integers: the lower and upper limits of each lock dial. For example, if the lower and upper limits were $$$3$$$ and $$$7$$$, respectively, then the lock dial could turn to 3, 4, 5, 6, or 7.
OutputOutput a single integer $$$c$$$: the total number of possible lock combinations.
ExamplesInput4 2 10 3 9 11 16 5 8Output
1512Input
3 1 2 1 3 11 12Output
12