Up posture of the refresh interval

Up posture of the refresh interval

TimeLimit:2000MS  MemoryLimit:128MB
64-bit integer IO format: %lld
Resolved | Click favorite | 4 people has a collection of this title
Problem Description

Value_Dragon is a rich man. New Year approached, so he was prepared red envelopes. But his red envelopes way is wonderful. He let n individuals in a row. Each selection period interval [l, r] in the 1-n send, to each individual section of a dollar. So made m times red. He wanted to know how much hair after intervals meet the following requirements in sub-interval [1, n] in there

  1. The total number of not less than this interval to get the money s

  2. The total number of this range may be divided into two disjoint sub-intervals each subinterval obtained and money is not less than w

(Note: a range of sub-intervals including itself)

Anti-pit reminders, such as a length of the interval [1,1], can not be split into two subintervals

Input

The first row is an array of data T represents the integer.
Next, with a T set of data
at the beginning of each data of four integers representing nmsw
Next m lines, each line is the two numbers L, r represents about interval [L, r] endpoint

Where T <= 10

n<=10^6,m<=10^5

0<l<=r<=n

0<=w<=s<10^8

Output

For each interval the number of data output line, meet the requirements of the representative

SampleInput
4
1 0 0 0

1000000 0 0 0

1000000 1 0 0
1 1000000

10 10 20 14
2 10
5 9
5 5
6 8
2 6
9 10
6 7
6 10
4 5
5 7
SampleOutput
0
499999500000
499999500000
8

Guess you like

Origin www.cnblogs.com/qq-1585047819/p/11272294.html