Created
July 1, 2017 21:09
-
-
Save MohamedTaha98/30f5f99b4e8143bda4658e652d2fe19a to your computer and use it in GitHub Desktop.
Problem Solving
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() { | |
long long n, k, check, pos; | |
cin >> n >> k; | |
if (n % 2 == 0) | |
check = n / 2; | |
else | |
check = (n / 2) + 1; | |
if (k <= check) | |
pos = (k * 2) - 1; | |
else | |
pos = (k - check) * 2; | |
cout << pos; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment