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 ...
随机推荐
- Echarts 饼图,legend样式美化
最后样式图: 实现代码: var myChart = echarts.init(document.getElementById('container')); let option = { /*{b}: ...
- 微盟&致远OA&聚水潭&YonSuite系统对接集成整体解决方案
前言:大部分的企业都可能只用一套系统组织架构复杂,业务流程繁琐,内部同时有OA系统.BI系统.ERP系统......且各个系统都需要独立登陆,造成IT部门数据监管困难!如何在同一套中台系统上关联多管理 ...
- [AI]生物本能vs机器人工程:谁才有“意识”?
[AI]生物本能vs机器人工程:谁才有"意识"? 引子 我们已经就人类意识的初级形式和高级形式进行了初步探讨.通过对比分析,我们将初级意识定义为可以无需高级意识参与的本能反应.而高 ...
- Unit_ptr数据类型的理解
1.相关代码理解 在看代码时,发现有用到 SOCKET 我去找它们的定义,发现有如下定义: typedef UINT_PTR SOCKET 又去看UINT_PTR,LONG_PTR, LONG_PT ...
- 神经网络入门篇:详解核对矩阵的维数(Getting your matrix dimensions right)
核对矩阵的维数 当实现深度神经网络的时候,其中一个常用的检查代码是否有错的方法就是拿出一张纸过一遍算法中矩阵的维数. \(w\)的维度是(下一层的维数,前一层的维数),即\({{w}^{[l]}}\) ...
- JUC_start和run
类型: run方法是同步 而start是异步 作用: run方法的作用是存放任务代码 ,start的方法是启动线程 线程数量方面: 执行run方法,他不会产生新线程,而执行start方法hi产生新 ...
- Oracle数据库卸载器 - 开源研究系列文章
今天无事,把网上搜到的Oracle数据库卸载器的软件更新到C#的Winform界面的操作上. 1. 程序目录: 与笔者的其它软件类似,目录如下: 2. 使用的类: 这里主要使用了一个处理函数: 3. ...
- ElasticSearch安装中文分词器(插件)、分词测试
https://github.com/medcl/elasticsearch-analysis-ik 分词测试: https://www.elastic.co/guide/en/elasticsear ...
- 什么是革命性技术eBPF?为什么可观测性领域都得用它
公众号「架构成长指南」,专注于生产实践.云原生.分布式系统.大数据技术分享. 如果有一种技术可以监控和采集任何应用信息,支持任何语言,并且应用完全无感知,零侵入,想想是不是很激动,那么这个技术是什么呢 ...
- vulnhub - tornado - wp
coverY: 0 tornado 信息收集 目标开放了80,22端口. 访问80网页,是默认页面: 目录枚举 用dirsearch没有什么发现,换gobuster发现了一个bluesky目录.访问如 ...