Skip to content

Instantly share code, notes, and snippets.

@MohamedTaha98
Created July 1, 2017 21:09
Show Gist options
  • Save MohamedTaha98/30f5f99b4e8143bda4658e652d2fe19a to your computer and use it in GitHub Desktop.
Save MohamedTaha98/30f5f99b4e8143bda4658e652d2fe19a to your computer and use it in GitHub Desktop.
Problem Solving
#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