【CF 1194A】Remove a Progression

                                  A. Remove a Progression

You have a list of numbers from 11 to nn written from left to right on the blackboard.

You perform an algorithm consisting of several steps (steps are 11-indexed). On the ii-th step you wipe the ii-th number (considering only remaining numbers). You wipe the whole number (not one digit).

【CF 1194A】Remove a Progression_第1张图片

When there are less than ii numbers remaining, you stop your algorithm.

Now you wonder: what is the value of the xx-th remaining number after the algorithm is stopped?

Input

The first line contains one integer TT (1≤T≤1001≤T≤100) — the number of queries. The next TT lines contain queries — one per line. All queries are independent.

Each line contains two space-separated integers nn and xx (1≤x

Output

Print TT integers (one per query) — the values of the xx-th number after performing the algorithm for the corresponding queries.

Example

input

3
3 1
4 2
69 6

output

2
4
12

题意:给出t个从1到n的数列,进行n次操作,第i次操作删除当前数列中第i个数,求最终数列中的第x个数是多少

 实际上就是隔一位删一位数,所以直接输出x*2即可

代码:

#include
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
 
int main()
{
	int t,n,m;
	cin>>t;
	while(t--)
	{
		cin>>n>>m;
		cout<

 19年暑假集训启程

你可能感兴趣的:(题解,CF,水题,思维)