fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6. long long n,k;
  7.  
  8. cin>>n>>k;
  9.  
  10. //cout<<n/2<<"\n";
  11. if(k<=n/2 && n%2==0){
  12. cout<<1+(k-1)*2<<"\n";
  13. }
  14. else if(k<=n/2+1 && n%2==1){
  15. cout<<1+(k-1)*2<<"\n";
  16. }
  17. else{
  18. long long t;
  19. if(n%2==0){
  20. t = k - n/2;
  21. }
  22. else t = k - n/2 - 1;
  23. cout<<2 +(t-1)*2<<"\n";
  24. }
  25.  
  26.  
  27.  
  28. }
  29.  
  30.  
  31.  
Success #stdin #stdout 0s 3472KB
stdin
284911189 142190783
stdout
284381565