A. Even Odds

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/318/problem/A

Description

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.

Sample Input

10 3

Sample Output

5

HINT

题意

给你n,然后把这些数按照先奇数和后偶数排序之后,输出第k个

题解:

很明显这是一道不是输出k*2+1就是输出k*2的答案

我们只要自己出几个无聊的数据测测就好了

代码:

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 2000001
#define mod 10007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** int main()
{
ll n=read(),k=read();
if(n%==)
{
if(k<=n/+)
printf("%lld",k*-);
else
printf("%lld",(k-n/-)*);
}
else
{
if(k<=n/)
printf("%lld",k*-);
else
printf("%lld",(k-n/)*);
}
}

Codeforces Round #188 (Div. 2) A. Even Odds 水题的更多相关文章

  1. Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)

    Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...

  2. Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题

    A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...

  3. Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/675/problem/A Description Vasya likes e ...

  4. Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题

    A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...

  5. Codeforces Round #146 (Div. 1) A. LCM Challenge 水题

    A. LCM Challenge 题目连接: http://www.codeforces.com/contest/235/problem/A Description Some days ago, I ...

  6. Codeforces Round #335 (Div. 2) B. Testing Robots 水题

    B. Testing Robots Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606 ...

  7. Codeforces Round #335 (Div. 2) A. Magic Spheres 水题

    A. Magic Spheres Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606/ ...

  8. Codeforces Round #306 (Div. 2) A. Two Substrings 水题

    A. Two Substrings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/pro ...

  9. Codeforces Round #333 (Div. 2) A. Two Bases 水题

    A. Two Bases Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/602/problem/ ...

随机推荐

  1. selenium python (六)定位一组对象

    checkbox源码: <html><head><meta http-equiv="content-type" content="text/ ...

  2. 配置spring管理的bean的作用域

    .singleton 在每一个spring Ioc容器中一个bean定义只有一个对象实例.默认情况下会在容器启动时初始化bean,但我们可以指定bean节点的lazy-init = "tru ...

  3. android 开发必用的开源库

    LogReport:  https://github.com/wenmingvs/LogReport,   崩溃日志上传框架 wcl-permission-demo:Android 6.0 - 动态权 ...

  4. 麒麟OS剽窃

    今年对于我们的IT行业来说可以算是耻辱的一年. 首先是“汉芯丑闻”,上海交大研制了一个所谓的国内第一个完全拥有自主知识产 权的DSP芯片(数字信号微处理器)——“汉芯”,研制人陈进教授以此领取政府一亿 ...

  5. express 学习笔记

    首先把这个库加载下来 npm install -g express 这样会安装它所有依赖包,这个非常恐怖.这个框架要依赖这么多外来的东西,如果有一个不与时俱进就会拖累整个框架的质量. C:\windo ...

  6. 关于Windows系统防火墙

    步入win7时代,一般用户,真的没必要再去找墙了,系统墙已经足够(如果你是外网用户,毫无疑问已经足够!如果你是局域网用户,加个ARP防火墙,足矣) 有人说,系统墙防外不错,防内就不行了,其实是误解.只 ...

  7. iOS 8自动调整UITableView和UICollectionView布局

    本文转载自:http://tech.techweb.com.cn/thread-635784-1-1.html 本文讲述了UITableView.UICollectionView实现 self-siz ...

  8. test是否被执行?

    procedure TForm2.Button1Click(Sender: TObject);  function test(value:boolean):boolean;  begin    res ...

  9. js set

    function ff(){ var sArray = ['a','b','b','b','b','b','d','b']; var iSet = {}; for(var i=0;i<sArra ...

  10. php中定义类

    <?php class Person{ //定义了一个Person类 public $name; //定义属性name public $age; //定义属性age function __con ...