Codeforce 318A - Even Odds(数学水题)
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(数学水题)的更多相关文章
- 天哪!毫无思绪!令人感到恐惧的数学(水题?)(TOWQs)
这道题的题目描述灰常简单,第一眼看以为是一道十分水的题目: 但是!!!(我仔细一看也没有发现这背后隐藏着可怕的真相~) 下面给出题目描述: 给出一个整数x,你可以对x进行两种操作.1.将x变成4x+3 ...
- hdu 2710 Max Factor 数学(水题)
本来是不打算贴这道水题的,自己却WA了三次.. 要考虑1的情况,1的质因子为1 思路:先打表 ,然后根据最大质因子更新结果 代码: #include<iostream> #include& ...
- ZOJ 1494 Climbing Worm 数学水题
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=494 题目大意: 一只蜗牛要从爬上n英寸高的地方,他速度为u每分钟,他爬完u需要 ...
- HDU 1840 Equations (简单数学 + 水题)(Java版)
Equations 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1840 ——每天在线,欢迎留言谈论. 题目大意: 给你一个一元二次方程组,a(X^2 ...
- lightoj 1148 Mad Counting(数学水题)
lightoj 1148 Mad Counting 链接:http://lightoj.com/volume_showproblem.php?problem=1148 题意:民意调查,每一名公民都有盟 ...
- zzulioj--1790-- 弹珠游戏(数学水题!)
弹珠游戏 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 14 Solved: 10 SubmitStatusWeb Board Descriptio ...
- zzulioj--1841--so easy!麻麻再也不用担心我的数学了!(数学水题)
1841: so easy!麻麻再也不用担心我的数学了! Time Limit: 1 Sec Memory Limit: 128 MB Submit: 27 Solved: 15 SubmitSt ...
- HDU 1408 盐水的故事 数学水题
http://acm.hdu.edu.cn/showproblem.php?pid=1408 题目: 挂盐水的时候,如果滴起来有规律,先是滴一滴,停一下:然后滴二滴,停一下:再滴三滴,停一下...,现 ...
- 【Comet OJ - Contest #0 A】解方程(数学水题)
点此看题面 大致题意: 给定自然数\(n\),让你求出方程\(\sqrt{x-\sqrt n}+\sqrt y-\sqrt z=0\)的自然数解\(x,y,z\)的数量以及所有解\(xyz\)之和. ...
- 【数学水题】【TOJ4113】【 Determine X】
题目大意: yuebai has a long sequence of integers A1,A2,-,AN. He also has such a function: F(x)=∑i=1N(⌊Ai ...
随机推荐
- LabVIEW基于机器视觉的实验室设备管理系统(4)
目录 行动计划 后面板连线 初始化 返回 注册 账号限制 查重账号或者姓名 确认密码 注册 效果演示 我们上一期制作完了给账户修改密码,那么我们这一期就来完成账户注册这一功能.老规矩哦,先来计划 ...
- 品牌全渠道营销系统如何与不同经销商ERP打通
品牌商在与各经销商ERP系统打通方面面临的挑战.传统的ERP系统往往使得数据收集和合作变得繁琐且低效,导致市场响应迟缓,影响整体的供应链管理和市场决策.我们的解决方案旨在破解这一难题,提供一个全渠道营 ...
- 第五周阅读笔记|人月神话————胸有成竹(Calling the Shot)
这个章节标题是胸有成竹,而要做到胸有成竹就必须在项目计划阶段我们对项目的预测和估算都需要很准确.因此整个章节的内容就是在讲估算,而估算就涉及到预测和估算模型,估算要做到准确必须通过前期多个历史项目和版 ...
- 【Javaweb】implements Serializable是什么意思?反序列化是什么意思?
为了保证数据传输的可靠 性,常常要implements Serializable,为什么? 对象本质上是虚无缥缈的,只是内存中的一个地址,如果想要让对象持久化,让对象在网络上传输,总不可能传送一个内存 ...
- [USACO2007NOVS] Cow Hurdles S
题目描述 Farmer John wants the cows to prepare for the county jumping competition, so Bessie and the gan ...
- C# 常量 结构体 委托
常量 const double PI = 3.1415926; 常量名命名一般使用大写字母 枚举类型 开发一个游戏,游戏角色有法师(Mage).射手(Archer).刺客(Assassin).坦克(T ...
- C++ Qt开发:SpinBox数值微调框组件
Qt 是一个跨平台C++图形界面开发库,利用Qt可以快速开发跨平台窗体应用程序,在Qt中我们可以通过拖拽的方式将不同组件放到指定的位置,实现图形化开发极大的方便了开发效率,本章将重点介绍QSpinBo ...
- .NET Conf China 2023 活动纪实 抢先看
今天2023年12月16日.NET Conf China 2023举办的日子,北京昨天上午还在飘起雪花,到今天早上的天气就有了极大的改观,大清早就能看到外面徐徐升起的朝阳,这也预示着今天将是一个大 ...
- dada的GCD ( jxnu acm新生选拔赛)
1007 dada的GCD,输入格式描述有误,已修正 dada的GCD Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/327 ...
- Qt+FFmpeg仿VLC接收RTSP流并播放
关键词:Qt FFmpeg C++ RTSP RTP VLC 内存泄漏 摘要认证 花屏 源码 UDP 本系列原文地址. 下载直接可运行的源码,在原文顶部. 效果 产生RTSP流 比播放文件复杂一点是, ...