P27947 [洛谷] "HCOI-R1" Change of Sorrow
提高-
题目描述

Problem Background

Ai loves numbers.

She also loves changes.

Problem Description

There is an integer \( a \) initially set to 1.

Ai wants to make \( a \) undergo exactly \( k \) changes, choosing from one of the following two changes each time:

  • \( a \gets a - 1 \);
  • \( a \gets a \times 2 \).

Ai is curious whether \( a \) can become \( n \) after exactly \( k \) changes.

Input Format

This problem contains multiple test cases.

The first line contains a positive integer \( T \), representing the number of test cases.

The next \( T \) lines each contain two integers, \( k \) and \( n \), representing a query from Ai.

Output Format

Output \( T \) lines. For each query, if \( a \) can become \( n \), output Yes; otherwise, output No.

Sample Input and Output

Sample Input #1

3
2 5
2 4
3 3

Sample Output #1

No
Yes
Yes

Sample Input #2

5
4 869
48 69
8 328
66 114514
168 1919810

Sample Output #2

No
Yes
No
Yes
Yes

Notes

Sample Explanation 1

  • For \( k = 2 \) and \( n = 5 \), it can be proven that there is no solution.
  • For \( k = 2 \) and \( n = 4 \), one possible sequence of operations is:
  • First step, \( a \gets a \times 2 = 2 \);
  • Second step, \( a \gets a \times 2 = 4 \).
  • For \( k = 3 \) and \( n = 3 \), one possible sequence of operations is:
  • First step, \( a \gets a \times 2 = 2 \);
  • Second step, \( a \gets a \times 2 = 4 \);
  • Third step, \( a \gets a - 1 = 3 \).

Data Size and Constraints

This problem uses batched testing.

  • Subtask 0 (10 pts): \( T \leq 10 \), \( k \leq 15 \).
  • Subtask 1 (25 pts): \( n, k \leq 2 \times 10^3 \).
  • Subtask 2 (65 pts): No additional constraints.

For all data, \( 1 \leq T \leq 10^5 \), \( 0 \leq n, k \leq 10^{18} \).

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 2 5 2 4 3 3
样例输出
No Yes Yes