Idea: divide n into [1,n/2],[n/2+1,n], if M is in the left interval, a=m+1, if M is in the right interval, a=m-1. But I forgot to deal with the special data of the hack.
Summary: Next time must pay attention to, before submitting must look at the boundary data, do not rush to hand over.
Title Link: Http://codeforces.com/problemset/problem/570/B
<pre name= "code" class= "CPP" > #include <bits/stdc++.h>using namespace std;int n,m;int Main (void) { int a ; scanf ("%d%d", &n,&m); if (n==1&&m==1)//Handle the 1\n {printf (""); } else {if (n&1) {if (m==n/2+1) a=n/2;//if n is odd, it happens that M is the most intermediate number, because to take the smallest, take the left number else if (m<n /2+1) a=m+1; else a=m-1; } else { if (M>N/2) a=m-1; else a=m+1; } printf ("%d\n", a); } return 0;}
Copyright NOTICE: Reprint must please indicate the source, thank you
Codeforces Round #316 (Div. 2) B. Simple Game