fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define GG ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  4. int main () { GG;
  5. long long n,k,x,ans;
  6. cin>>n>>k;
  7. x=n/2;
  8. if(n%2!=0) x++;
  9.  
  10. if(k<=x)
  11. ans=1+(2* (k-1) );
  12. else
  13. ans=2+(2* (k-x-1) );
  14.  
  15. cout<<ans<<"\n";
  16. return 0;}
Success #stdin #stdout 0s 5304KB
stdin
7 5
stdout
2