#P10026. 「HCOI-R1」哀之变化

「HCOI-R1」哀之变化

Background

Ai likes numbers.

She also likes transformations.

Problem Description

There is an integer aa that starts as 11.

Ai wants aa to undergo exactly kk transformations. Each time, she chooses one of the following two transformations:

  • aa1a \gets a - 1;
  • aa×2a \gets a \times 2.

Ai is curious whether, after exactly kk transformations, aa can become nn.

Input Format

This problem contains multiple test cases.

The first line contains a positive integer TT, representing the number of test cases.

The next TT lines each contain two integers, in order kk and nn, representing one query from Ai.

Output Format

Output TT lines. For each query, if aa can become nn, output Yes; otherwise output No.

3
2 5
2 4
3 3
No
Yes
Yes
5
4 869
48 69
8 328
66 114514
168 1919810

No
Yes
No
Yes
Yes

Hint

Sample Explanation 1

  • If k=2k = 2 and n=5n = 5, it can be proven that there is no solution.
  • If k=2k = 2 and n=4n = 4, one possible sequence of operations is:
    • Step 1: aa×2=2a \gets a\times 2 = 2;
    • Step 2: aa×2=4a \gets a\times 2 = 4.
  • If k=3k = 3 and n=3n = 3, one possible sequence of operations is:
    • Step 1: aa×2=2a \gets a\times 2 = 2;
    • Step 2: aa×2=4a \gets a\times 2 = 4.
    • Step 3: aa1=3a \gets a-1 = 3.

Constraints

This problem uses bundled testdata.

  • Subtask 0 (10 pts): T10T \leq 10, k15k \leq 15.
  • Subtask 1 (25 pts): n,k2×103n, k \leq 2\times 10^3.
  • Subtask 2 (65 pts): No special constraints.

For all testdata, 1T1051 \leq T \leq 10^5, 0n,k10180 \leq n, k \leq 10^{18}.

Translated by ChatGPT 5