Being a nonconformist, Volodya is displeased with the current state of things, particularly with the order of natural numbers (natural number is positive integer number). He is determined to rearrange them. But there are too many natural numbers, so Volodya decided to start with the first n. He writes down the following sequence of numbers: firstly all odd integers from 1 to n (in ascending order), then all even integers from 1 to n (also in ascending order). Help our hero to find out which number will stand at the position number k.
作為一個不墨守成規的人,Volodya 對事物的當前狀態感到不滿,尤其是對自然數的順序(自然數是正整數)感到不滿。 他決心重新安排它們。 但是自然數太多了,所以 Volodya 決定從第一個 n 開始。 他寫下以下數字序列:首先是從 1 到 n 的所有奇數(升序),然後是從 1 到 n 的所有偶數(也是升序)。 幫助我們的英雄找出哪個數字將站在第 k 位。
The only line of input contains integers n and k (1 ≤ k ≤ n ≤ 1012).
Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.
唯一的輸入行包含整數 n 和 k (1 ≤ k ≤ n ≤ 1012)。
請不要使用 %lld 說明符在 C++ 中讀取或寫入 64 位整數。 最好使用 cin、cout 流或 %I64d 說明符。
Print the number that will stand at the position number k after Volodya's manipulations.
打印在 Volodya 操作後將位於位置編號 k 的數字。
10 3
5
7 7
6
In the first sample Volodya's sequence will look like this: {1, 3, 5, 7, 9, 2, 4, 6, 8, 10}. The third place in the sequence is therefore occupied by the number 5.
在第一個示例中,Volodya 的序列將如下所示:{1, 3, 5, 7, 9, 2, 4, 6, 8, 10}。 因此,序列中的第三位被數字 5 佔據。
ID | User | Problem | Subject | Hit | Post Date |
沒有發現任何「解題報告」 |