HDU 5523 Game
坑题
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int main() { int N,S,T; while(~scanf("%d%d%d",&N,&S,&T)) { if((S==1&&T==N)||(S==N&&T==1)) { printf("0\n"); continue; } if(S==T) { printf("-1\n"); continue; } if((1<S&&S<T&&T<N)||(1<T&&T<S&&S<N)) { if(abs(S-T)==1) { printf("1\n"); continue; } else if(abs(S-T)!=1) { printf("2\n"); continue; } } if(S==1||S==N) { printf("1\n"); continue; } if(T==1||T==N) { if(abs(T-S)==1) printf("1\n"); else printf("2\n"); continue; } } return 0; }