#735
Unrated
Lineup Counting Queries
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

There is a line of cows, initially (i.e. at time t=0t = 0) containing only cow 00 at position 00 (here, a cow is at position kk if there are kk cows in front of it). At time tt for t=1,2,3,t=1,2,3,\dots, the cow at position 0 moves to position t/2\lfloor t/2\rfloor, every cow in positions 1t/21\dots \lfloor t/2\rfloor moves forward one position, and cow tt joins the line at the end of the line (position tt).

Answer QQ (1Q1051\le Q\le 10^5) independent queries each of the following form:

Out of cows l1r1l_1\dots r_1, how many are located at positions l2r2l_2\dots r_2 immediately after time tt? (0l1r1t,0l2r2t,t10180\le l_1\le r_1\le t, 0\le l_2\le r_2 \le t, t\le 10^{18})

입력

The first line contains QQ, the number of queries.

The next QQ lines each contain five integers specifying a query of the form "l1l_1 r1r_1 l2l_2 r2r_2 tt."

출력

Output the answer to each query on a separate line.

예제 입력 1

4
0 9 0 9 9
3 5 4 5 9
4 5 3 5 9
1 1 3 3 9

예제 출력 1

10
2
1
1

예제 입력 2

1
0 1000000000000000000 0 1000000000000000000 1000000000000000000

예제 출력 2

1000000000000000001

점수

Input 3: Q1000,t100Q\le 1000, t\le 100Inputs 4-7: l1=r1l_1 = r_1 for all queriesInputs 8-14: r12l1r_1 \leq 2 \cdot l_1 for all queriesInputs 15-21: No additional constraints

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.