Advertisement
Nusrat_Ullah

CF 546_div2 - B

Mar 11th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int q,w,z,x,re=0;
  6.     scanf("%d %d",&q,&w);
  7.     z=q-w;
  8.     x=w-1;
  9.     if(q==1)re+=2;
  10.     else{
  11.         re+=((q-1)*2);
  12.         re+=3;
  13.     }
  14.     if(x&&z)
  15.         if(x<z)re+=(2*x);
  16.         else re+=(2*z);
  17.     if(x&&z<x)re+=x;
  18.     if(z&&x<z)re+=z;
  19.     printf("%d\n",re);
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement