Logo
(追記) (追記ここまで)

20615번 - Distinct Number 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB61150.000%

문제

Given $n$ intervals $[l_1,r_1], [l_2,r_2], \ldots, [l_n, r_n]$ and an integer $x,ドル you should find the size of the set $S = \{y \mid y = i \operatorname{AND} x, ,円 i \in [l_1, r_1] \cup [l_2, r_2] \cup \ldots \cup [l_n, r_n]\},ドル where $i\operatorname{AND} x$ is the bitwise and of integers $i$ and $x$.

입력

There are multiple test cases. The first line of input contains an integer $T,ドル indicating the number of test cases. For each test case:

The first line contains two integers $n$ and $x$ (1ドル \le n \le 5 \cdot 10^3,ドル 0ドル \le x \le 10^{18}$).

Each of the next $n$ lines contains two integers $l_i$ and $r_i$ (0ドル \le l_i \le r_i \le 10^{18}$).

It is guaranteed that the sum of $n$ over all test cases does not exceed 5ドル \cdot 10^3$.

출력

For each test case, output an integer denoting the size of the set $S$.

제한

예제 입력 1

3
2 1
1 2
343 34345
1 3
1 3
1 123242343
1 1000000000000000000

예제 출력 1

2
3
32768

힌트

For the first sample test case, we have $S = \{0, 1\},ドル so the answer is 2ドル$.

For the second sample test case, we have $S = \{1, 2, 3\},ドル so the answer is 3ドル$.

출처

Camp > Petrozavodsk Programming Camp > Summer 2020 > Day 4: Xi Lin Contest 6 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /