【链接】 我是链接,点我呀:)
【题意】
【题解】
肯定是放在m-1或者m+1的。 (m-1是左边的点都离a最近,而m+1则是右边的点都离他最近。 看看哪个更好就行【代码】
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m;
int main()
{
ios::sync_with_stdio(0),cin.tie(0);
#ifdef LOCAL_DEFINE
freopen("rush.txt","r",stdin);
#endif // LOCAL_DEFINE
cin >> n >> m;
if (m==1){
return cout<<min(n,1LL*2)<<endl,0;
}
if (m==n){
return cout<<max(1LL,n-1)<<endl,0;
}
int x = m-1,y = n-(m+1)+1;
if (x>=y){
cout <<m-1<<endl;
}else{
cout <<m+1<<endl;
}
return 0;
}