0w1

CFR 570 B. Simple Game ( Ad hoc )

Problem - B - Codeforces
Imagine the tile that occupies the range. Mark the position where the other player had chosen beforehand. It is now obvious that we will choose the range with greater range, and put ours exactly next to the foe's. However, be careful for the case where N == 1.

void solve(){
    int N, M; cin >> N >> M;
    if( N == 1 and M == 1 ){
        cout << 1 << endl;
        return;
    }
    int u = N - M;
    int v = M - 1;
    if( u > v ) cout << M + 1 << endl;
    else cout << M - 1 << endl;
}