Classic
Clean & simple
Crystal
Glassmorphism + Neon
Cyberpunk
Neon glitch art
🚫
违规Action检测
禁止Use右键菜单
⚠️ 此Action已被系统记录
1

Even Odds

📝 Solutions 🔵 仅限 C++
Problems Description
<div class="page"> <div class="layoutArea"> <div class="column"> <p> <span style="line-height:1.5;">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</span> </p> <p> integers from 1 to n (also in ascending order). Help our hero to find out which number will stand at the position number k. </p> <p> &nbsp; </p> <p> Input </p> <p> The only line of input contains integers n and k (1≤k≤n≤1e14). &nbsp; </p> <p> Output </p> <p> Print the number that will stand at the position number k after Volodya's manipulations. &nbsp; </p> <p> &nbsp; </p> <p> Sample test(s) input<br /> 10 3 </p> <p> 77 </p> <p> output </p> <p> 5 </p> <p> 6 </p> <p> Note </p> <p> 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. </p> <p> Hint </p> <p> 注意数据的类型 </p> <p> use __int64 to read data and use %I64d to output data&nbsp; </p> </div> </div> </div>
Input格式
<span>The only line of input contains integers n and k (1≤k≤n≤1e14). &nbsp;</span>
Output格式
<span>Print the number that will stand at the position number k after Volodya's manipulations. &nbsp;</span>
Sample
Sample Input 1
10 3 7 7
Sample Output 1
5 6
Submit Code
请先Login后Submit

🤖 AI 解题助手

OpenRouter
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这problems题,可以帮你points析思路、提供Code示例。
🔓 完全Free · 无需消耗 Token