Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
unsigned long long n, m;
cin>>n>>m;
if(n & 1){
(m <= (n/2 + 1)) ? cout<<(2 * m - 1)<<endl : cout<<(2*(m - (n/2 + 1)))<<endl;
return 0;
}
(m <= n/2) ? cout<<(2 * m - 1)<<endl : cout<<(2*(m - n/2))<<endl;
return 0;
}
Copy The Code &
Try With Live Editor
Input
10 3
Output
5
Demonstration
Codeforcess Solution 318-A A. Even Odds ,C++, Java, Js and Python ,318-A,Codeforcess Solution