注意wa点:1 1 输出1
AC代码:
#include "iostream"
#include "cstdio"
#include "cstring"
#include "algorithm"
#include "map"
using namespace std;
int n, m;
int main(int argc, char const *argv[])
{
scanf("%d%d", &n, &m);
int r1 = -1, r2 = -1;
if(n == 1) printf("1\n");
else {
if(m != n) r1 = n - m;
if(m != 1) r2 = m - 1;
if(r1 > r2) printf("%d\n", m + 1);
else printf("%d\n", m -1);
}
return 0;
}