Problem B: 占点游戏

传送门:http://gdutcode.sinaapp.com/problem.php?cid=1057&pid=1

解题思路:

注可以把两个点简化到一条直线上来思考。

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        int n,x1,y1,x2,y2;
        scanf("%d%d%d%d%d",&n,&x1,&y1,&x2,&y2);
        int d=abs(x1-x2)+abs(y1-y2);
        int ans=0;
        if((n+1)/2<d){
            ans=n&1;
        }else{
            //d是奇数先走可以踩到对方的点
            if(d&1){
               if(n&1)
                    ans=2;
            }else{
                ans=1;
            }
        }
        if(ans==0)
            cout<<-1<<endl;
        else
            cout<<ans<<endl;

    }
}
自己选的路,跪着也要把它走完------ACM坑
原文地址:https://www.cnblogs.com/IKnowYou0/p/6636440.html