410124: GYM103960 D Displacing Particles

Memory Limit:1024 MB Time Limit:0 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

D. Displacing Particlestime limit per test0.25 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output

A square has its vertices at the coordinates $$$(0, 0), (0, 2^N), (2^N, 2^N), (2^N, 0)$$$. Each vertex has an attractor. A particle is placed initially at position $$$(2^{N-1}, 2^{N-1})$$$. Each attractor can be activated individually, any number of times. When an attractor at position $$$(i, j)$$$ is activated, if a particle is at position $$$(p, q)$$$, it will be moved to the midpoint between $$$(i, j)$$$ and $$$(p, q)$$$.

Given $$$N$$$ and a point $$$(x, y)$$$, calculate the least number of times you have to activate the attractors so that the particle ends up at position $$$(x, y)$$$. You may assume that for all test cases a solution exists.

Input

The input consists of a single line containing three integers $$$N$$$, $$$x$$$ and $$$y$$$, such that $$$1 \leq N \leq 20$$$ and $$$0 < x, y < 2^N$$$.

Output

Print a single line, containing the least number of times you have to active the attractors.

ExamplesInput
1 1 1
Output
0
Input
4 12 4
Output
1
Input
4 3 1
Output
3

加入题单

上一题 下一题 算法标签: