A Leapfrog in the Array

题意翻译

## 题意: Dima是一名初级程序员。 在他的工作中,他经常不断地重复以下操作:从数组中删除每个第二个元素。 有一天,他对这个问题的解决方案感到厌倦,他提出了以下华丽的算法。 假设有一长度为2n的数组,最初的数组包含从1到n的n个数字,数字i位于序号为2i - 1的单元格中(序号从1开始编号),并且数组的其他单元格为空。每个步骤你需要选择一个最大序号的非空单元格,并将其中的数字移动到它左边最近的空单元格。一直循环该过程,直到所有n个数字出现在数组的前n个单元格中。例如,如果n = 4,则数组更改如下: ![这里写图片描述](http://codeforces.com/predownloaded/1e/83/1e838f4fb99d933b7259fbfe5b8722990c08d718.png) 您必须编写一个程序,输出在该算法完成后,序号为x(1≤x≤n)的单元格中的数字。 ## 输入格式: 第一行包含两个整数n和q(1≤n≤1e18,1≤q≤200 000),数组中元素的数量以及查询数量。 接下来的q行包含一个整数xi(1≤xi≤n),xi为算法完成后,第xi个单元格。 ## 输出格式: 对于q个查询中的每一个,输出一个整数,即相应数组单元格中的值。 ## 样例: ``` inputCopy 4 3 2 3 4 outputCopy 3 2 4 ``` ``` inputCopy 13 4 10 5 4 8 outputCopy 13 3 8 9 ``` 翻译提供者:xjdx

题目描述

Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this problem, and he has come up with the following extravagant algorithm. Let's consider that initially array contains $ n $ numbers from $ 1 $ to $ n $ and the number $ i $ is located in the cell with the index $ 2i-1 $ (Indices are numbered starting from one) and other cells of the array are empty. Each step Dima selects a non-empty array cell with the maximum index and moves the number written in it to the nearest empty cell to the left of the selected one. The process continues until all $ n $ numbers will appear in the first $ n $ cells of the array. For example if $ n=4 $ , the array is changing as follows: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF949B/7e8d4ceedf49e6772b560ab16787b840f4d4ddb2.png)You have to write a program that allows you to determine what number will be in the cell with index $ x $ ( $ 1<=x<=n $ ) after Dima's algorithm finishes.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ q $ ( $ 1<=n<=10^{18} $ , $ 1<=q<=200000 $ ), the number of elements in the array and the number of queries for which it is needed to find the answer. Next $ q $ lines contain integers $ x_{i} $ ( $ 1<=x_{i}<=n $ ), the indices of cells for which it is necessary to output their content after Dima's algorithm finishes.

输出格式


For each of $ q $ queries output one integer number, the value that will appear in the corresponding array cell after Dima's algorithm finishes.

输入输出样例

输入样例 #1

4 3
2
3
4

输出样例 #1

3
2
4

输入样例 #2

13 4
10
5
4
8

输出样例 #2

13
3
8
9

说明

The first example is shown in the picture. In the second example the final array is $ [1,12,2,8,3,11,4,9,5,13,6,10,7] $ .