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 ...
随机推荐
- Python+Yolov8+ONNX实时缺陷目标检测
相比于上一篇Windows10+Python+Yolov8+ONNX图片缺陷识别,并在原图中标记缺陷,有onnx模型则无需配置,无需训练. 优化了程序逻辑,降低了程序运行时间,增加了实时检测功能 目录 ...
- 函数计算的新征程:使用 Laf 构建 AI 知识库
Laf 已成功上架 Sealos 模板市场,可通过 Laf 应用模板来一键部署! 这意味着 Laf 在私有化部署上的扩展性得到了极大的提升. Sealos 作为一个功能强大的云操作系统,能够秒级创建多 ...
- Linux 运维人员最常用 150+命令汇总
版权声明:原创作品,谢绝转载!否则将追究法律责任. ----- 作者:kirin 目录 版权声明:原创作品,谢绝转载!否则将追究法律责任. ----- 作者:kirin 命令帮助手册1 命令帮助手册2 ...
- Windows风格的个人网盘,支持文档在线编辑
这是一个Windows页面风格的个人网盘,支持普通文本.文档.表格.xmind等在线编辑,支持Windows的小组件,例如计算器.WhiteBoard.python 等,其他更多功能待你来发现,也待你 ...
- [CF568E] Longest Increasing Subsequence
题目描述 Note that the memory limit in this problem is less than usual. Let's consider an array consisti ...
- k8s安装网络插件calico出现error validating "calico.yaml": error validating data: invalid object to validate; if you choose to ignore these errors, turn validation off with --validate=false
解决办法:使用下面版本的calico curl https://docs.projectcalico.org/v3.20/manifests/calico.yaml -O
- 【2016】CloneCD和IsoBuster配合使用以提取VCD中的文件
**笔记记录于:2016-11-24 ** 本文章仅供用于技术研究用途,请勿利用文章内容操作用于违反法律的事情. 起因: 公司老总让我提取下VCD中的文件以备份下,但是把光碟放进DVD光驱中发现只有几 ...
- u盘加密原理和实现步骤
U盘加密原理:U盘加密的原理主要是通过对U盘存储的数据进行加密处理,确保只有经过授权的用户才能访问和解密数据.以下是一般的U盘加密原理: 加密算法: 使用强大的加密算法对U盘中的数据进行加密.常见的算 ...
- NetSuite 开发日记:SDF 基础指南
VS Code 使用 SDF SuiteCloud : Create Project SuiteCloud : Set Up Account (连接沙盒环境) SuiteCloud : Import ...
- pytest框架学习-标签@pytest.mark.
标签 自定义标签(区分大小写) 可以标记测试用例,对测试用例进行分组,有利于对测试用例进行筛选. 比如:给用例打标为API,代表接口自动化的用例,打标方法为@pytest.mark.API,打标后,需 ...