# PROBLEM LINK:

Practice

Contest: Division 1

Contest: Division 2

Contest: Division 3

Contest: Division 4

* Author:* iceknight1093

*wasd2401*

**Tester:***iceknight1093*

**Editorialist:**# DIFFICULTY:

TBD

# PREREQUISITES:

None

# PROBLEM:

Given N, K, X, does there exist a superincreasing array of N positive integers whose K-th element is X?

# EXPLANATION:

It’s not hard to observe that indices after K don’t matter at all - if it’s possible to place A_K = X, further indices can always be filled by choosing some sufficiently large values (one simple way is to use 2K, 4K, 8K, \ldots at those indices).

So, all we need to do is decide whether there’s a way to make a superincreasing array of length K-1, whose sum is \lt X - if we can do this, X can be appended to it as the K-th element.

Since we want the sum to be \lt X, it makes sense to try and attain the smallest possible sum as well; since we can always increase it to obtain X after that.

To that end,

- The first element might as well be 1, the minimum possible value.
- The second element, A_2, can’t be 1, so let’s make it 2.
- A_3 now has to be greater than 1+2 = 3, so let’s make it 4.
- A_4 has to be greater than 1+2+4=7, so let’s make it 8.

\vdots - A_i will equal 2^{i-1}.

The smallest value that can occur at index K is thus 2^{K-1}.

## A more formal proof

The statement can be proved using induction.

Our claim is that the sum of the first i values of a superincreasing array is *at least* 2^{i-1} - 1.

For i = 1 this is trivially true: the sum of everything before it is 0 (there’s nothing there), which is 2^0 - 1.

Now, suppose the statement is true for i \geq 1.

Then, since A_{i+1} \gt A_1 + A_2 + \ldots + A_i, and by the inductive hypothesis the latter summation is at least 2^{i-1} - 1, we have A_{i+1} \gt 2^{i-1} - 1.

So,

The sum of the first i+1 elements is strictly greater than 2^{i} - 2, meaning it’s at least 2^i - 1 (since we’re working with integers) as claimed; and induction completes the proof.

In other words, the answer is `Yes`

if X \geq 2^{K-1} and `No`

otherwise.

Note that K can be quite large, so checking this by directly computing 2^{K-1} might not work.

Instead, you can observe that since X \leq 10^9 \lt 2^{30}, if K \geq 31 the answer is always `No`

.

For K \leq 30, X can be directly compared against 2^{K-1} since everything fits in a 32-bit integer.

# TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

# CODE:

## Editorialist's code (Python)

```
for _ in range(int(input())):
n, k, x = map(int, input().split())
if k >= 32: print('No')
else: print('Yes' if x >= 2**(k-1) else 'No')
```