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 ...
随机推荐
- GMAC网卡Fixed-Link模式
GMAC网卡Fixed-Link模式 GMAC fixed-link固定链接模式,mac与对端的连接方式是写死的,通常用于mac to mac(不排除mac to phy的情况).内核要支持fixed ...
- 下载神器——you-get
下载神器--you-get 01. you-get下载 you-get是一个基于Python3开发的开源项目. 某些网站的音视频资源,本身不提供下载功能,通过you-get,可以通过几条简单的命令去下 ...
- 一步解决Cannot resolve symbol 'WebServlet'(@WebServlet注解标红)
右键项目名(javaweb01)->Open Module Settings Modules->Dependencies->点击Export上面的,添加Tomcat即可
- [THUPC 2023 初赛] 背包
题目描述 本题中,你需要解决完全背包问题. 有 \(n\) 种物品,第 \(i\) 种物品单个体积为 \(v_i\).价值为 \(c_i\). \(q\) 次询问,每次给出背包的容积 \(V\),你需 ...
- [CF1325E] Ehab's REAL Number Theory Problem
Ehab's REAL Number Theory Problem 题目描述 You are given an array $ a $ of length $ n $ that has a speci ...
- wait/sleep的不同
整体的区别其实是有四个:1.所属类不同: sleep是线程中的方法,但是wait是Object中的方法.2.语法不同: sleep方法不依赖于同步器synchronized,但是wait需要依赖syn ...
- .NET开发中合理使用对象映射库,简化和提高工作效率
前言 在日常开发中,我们常常需要将一个对象映射到另一个对象,这个过程中可能需要编写大量的重复性代码,如果每次都手动编写,不仅会影响开发效率,而且当项目越来越复杂,庞大的时候还容易出现错误.为了解决这个 ...
- 【并发编程特性】并发编程特性之五种特性的探讨-volatileandsynchronized
title: [并发编程特性]并发编程特性之五种特性的探讨 date: 2021-11-18 10:16:05.492 updated: 2021-12-26 17:43:10.414 url: ht ...
- Spring 事务的实现原理
在执行访问数据库相关的操作中,特别是针对数据的修改操作,由于对于数据的修改可能会出现异常,因此对于整个一组的数据修改实际上都不能算是生效的,在这种情况下,需要使用事务的 "回滚" ...
- Tailscale 基础教程:Headscale 的部署方法和使用教程
Tailscale 是一种基于 WireGuard 的虚拟组网工具,它在用户态实现了 WireGuard 协议,相比于内核态 WireGuard 性能会有所损失,但在功能和易用性上下了很大功夫: 开箱 ...