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.

Input

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.

Output

Print the number that will stand at the position number k after Volodya's manipulations.

Examples

input

Copy

10 3

output

Copy

5

input

Copy

7 7

output

Copy

6

Note

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.

数学水题

#include<bits/stdc++.h>
using namespace std;
int main() {
long long n , k ; cin >> n >> k;
cout << ((n + 1) / 2 >= k ? k * 2 - 1 : 2 * (k - (n + 1) / 2));
}

Codeforce 318A - Even Odds(数学水题)的更多相关文章

  1. 天哪!毫无思绪!令人感到恐惧的数学(水题?)(TOWQs)

    这道题的题目描述灰常简单,第一眼看以为是一道十分水的题目: 但是!!!(我仔细一看也没有发现这背后隐藏着可怕的真相~) 下面给出题目描述: 给出一个整数x,你可以对x进行两种操作.1.将x变成4x+3 ...

  2. hdu 2710 Max Factor 数学(水题)

    本来是不打算贴这道水题的,自己却WA了三次.. 要考虑1的情况,1的质因子为1 思路:先打表 ,然后根据最大质因子更新结果 代码: #include<iostream> #include& ...

  3. ZOJ 1494 Climbing Worm 数学水题

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=494 题目大意: 一只蜗牛要从爬上n英寸高的地方,他速度为u每分钟,他爬完u需要 ...

  4. HDU 1840 Equations (简单数学 + 水题)(Java版)

    Equations 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1840 ——每天在线,欢迎留言谈论. 题目大意: 给你一个一元二次方程组,a(X^2 ...

  5. lightoj 1148 Mad Counting(数学水题)

    lightoj 1148 Mad Counting 链接:http://lightoj.com/volume_showproblem.php?problem=1148 题意:民意调查,每一名公民都有盟 ...

  6. zzulioj--1790-- 弹珠游戏(数学水题!)

    弹珠游戏 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 14  Solved: 10 SubmitStatusWeb Board Descriptio ...

  7. zzulioj--1841--so easy!麻麻再也不用担心我的数学了!(数学水题)

    1841: so easy!麻麻再也不用担心我的数学了! Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 27  Solved: 15 SubmitSt ...

  8. HDU 1408 盐水的故事 数学水题

    http://acm.hdu.edu.cn/showproblem.php?pid=1408 题目: 挂盐水的时候,如果滴起来有规律,先是滴一滴,停一下:然后滴二滴,停一下:再滴三滴,停一下...,现 ...

  9. 【Comet OJ - Contest #0 A】解方程(数学水题)

    点此看题面 大致题意: 给定自然数\(n\),让你求出方程\(\sqrt{x-\sqrt n}+\sqrt y-\sqrt z=0\)的自然数解\(x,y,z\)的数量以及所有解\(xyz\)之和. ...

  10. 【数学水题】【TOJ4113】【 Determine X】

    题目大意: yuebai has a long sequence of integers A1,A2,-,AN. He also has such a function: F(x)=∑i=1N(⌊Ai ...

随机推荐

  1. VisionPro学习笔记(5)——极轴展开工具PolarUnwrapTool

    如果需要了解其他图像处理的文章,请移步小编的GitHub地址 传送门:请点击我 如果点击有误:https://github.com/LeBron-Jian/ComputerVisionPractice ...

  2. mysql 安装避坑指南 ,mysql 安装后不能启动, mysql 指定版本安装,mysql 5.7.39版本安装,mysql 5.7.36版本安装

    mysql 安装后不能启动,报错如下:请参照本说明第7条的办法解决.mysqld.service: Control process exited, code=exited status=1Please ...

  3. Access denied for user ‘root‘@‘localhost‘ (using password:YES)解决方法

    修改jdbc.properties文件的密码

  4. C++ 邮件槽ShellCode跨进程传输

    在计算机安全领域,进程间通信(IPC)一直是一个备受关注的话题.在本文中,我们将探讨如何使用Windows邮件槽(Mailslot)实现ShellCode的跨进程传输.邮件槽提供了一种简单而有效的单向 ...

  5. Chrome扩展的核心:manifest 文件(中)

    大家好,我是 dom 哥.我正在写关于 Chrome 扩展开发的系列文章,感兴趣的可以 点个小星星 . 在上一篇中已经完成了 Chrome 扩展的雏形,本篇接着介绍 manifest 中的可选字段,完 ...

  6. 最后一次迭代——城院GO导航

    1. 程序运行截图展示: 2. 程序开发分工详情 葛方杰:负责地点汇总界面的前端基本界面设计以及上导航栏和侧导航栏的布局以及简单的数据绑定,以及做了自定义组件卡,用瀑布流的形式封装自定义组件卡来展现地 ...

  7. .NET周刊【12月第1期 2023-12-06】

    国内文章 .NET 与 OpenEuler 共展翅,昇腾九万里 https://www.cnblogs.com/shanyou/p/17858385.html 本文介绍了openEuler操作系统,它 ...

  8. svelte的一些基础demo

    脚手架 Vite:vite是集成了svelte,初始化的时候选择svelte就行了. npm init vite SvelteKit:底层基于vite的更上层框架,类似于nextjs. npm cre ...

  9. HP LoadRunner 11.00安装+破解+汉化

    里面包含多个破解码,最高支持6.5w个并发: https://blog.csdn.net/xianjie0318/article/details/78625980

  10. ElasticSearch之健康状态

    参考Cluster health API. 命令样例,如下: curl -X GET "https://localhost:9200/_cluster/health?wait_for_sta ...