A - Treasure Hunt CodeForces - 817A(思路:靠感觉?)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Miranda_ymz/article/details/83865800

A - Treasure Hunt CodeForces - 817A(思路:靠感觉?)

题目:给出船的位置和保障的位置,以及船可以的移动方式。(±x,±y)

思路:很迷的就写对了。感觉就是一个判断条件。同为奇偶就好了。还有两地的差值能被xy整除。 

#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int x1,x2,y1,y2;
    int x,y;
    scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x,&y);
    x2-=x1;//
    y2-=y1;//宝藏和船的差距。
    if(x2%x==0&&y2%y==0)
    {
        if(((x2/x)&1)&&((y2/y)&1)||!((x2/x)&1)&&!((y2/y)&1))
            printf("YES\n");
        else printf("NO\n");
    }
    else
        printf("NO\n");

    return 0;
}

猜你喜欢

转载自blog.csdn.net/Miranda_ymz/article/details/83865800
今日推荐