fork(15) download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4. #include <stdlib.h>
  5.  
  6. int main() {
  7. int T;
  8. long int N,K;
  9. scanf("%d\n",&T);
  10. while(T--)
  11. {
  12. scanf("%ld%ld",&N,&K);
  13. if(K < (N/2))
  14. printf("%ld\n",(2*K + 1));
  15. else
  16. printf("%ld\n",2*((N-1)-K));
  17. }
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 2056KB
stdin
2
3 1
5 2
stdout
2
4