F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Desiderium

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1054    Accepted Submission(s): 490


Problem Description
There is a set of intervals, the size of this set is $n$.

If we select a subset of this set with equal probability, how many the expected length of intervals' union of this subset is?

We assume that the length of empty set's union is 0, and we want the answer multiply $2^n$ modulo $10^9 + 7$.
 

Input
The first line of the input is a integer $T$, meaning that there are $T$ test cases.

Every test cases begin with a integer $n$ ,which is size of set.

Then $n$ lines follow, each contain two integers $l , r$ describing a interval of $[l , r]$.

$1 \leq n \leq 100,000$.

$-1,000,000,000 \leq l \leq r \leq 1,000,000,000$.
 

Output
For every test case output the answer multiply $2^n$ modulo $10^9 + 7$.
 

Sample Input
2 1 0 1 2 0 2 1 3
 

Sample Output
1 7
 

Hint
For the second sample, the excepted length is $\frac{0+2+2+3}{4}=\frac{7}{4}$.
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-06 16:26:03, Gzip enabled