#B4225. Merging Consecutive Numbers with Parity Averaging

    ID: 11882 Type: Default 1000ms 256MiB

Merging Consecutive Numbers with Parity Averaging

Merging Consecutive Numbers with Parity Averaging

On a blackboard, Little Y writes consecutively all positive integers from a to b (i.e. a, a+1, a+2, …, b). After that, he performs a series of operations. In each operation, he chooses two numbers that have the same parity (i.e. both odd or both even), erases them from the board, and writes their average (calculated as \(\frac{u+v}{2}\)) at the position of the earlier number. Note that the average is always an integer because the sum of two numbers with the same parity is even.

The question is: Is it possible, after performing a sequence of valid operations (possibly in different orders), to reduce the board to exactly one number equal to a given target x?

Note: The operations are done in such a way that the relative order of the remaining numbers is preserved. You may choose any valid operations in any order.

Example: For a = 1, b = 3 the board initially is [1, 2, 3]. The only possible operation is to merge 1 and 3 (both odd) into \(\frac{1+3}{2} = 2\), thus yielding [2, 2]. Merging the two 2's (even) gives \(\frac{2+2}{2} = 2\); hence, the only final number is 2.

inputFormat

The input consists of a single line containing three space‐separated positive integers: a, b and x, where a and b denote the starting and ending numbers on the board (a ≤ b), and x is the target number.

outputFormat

Output a single line with Yes if it is possible to perform a sequence of operations such that the final number on the board is x, or No otherwise.

sample

1 1 1
Yes