Educational Codeforces Round 23#A. Treasure Hunt
程序员文章站
2022-07-07 22:52:40
...
题意:
1. 一张二维图
2. 给你起点和终点坐标
3. 给你基础移动的能力(限定在基础移动上的四种移动方法)
4. 能到终点就cout YES ,否则cout NO
思路:
1. 如果x方向或y方向不能通过整数次变换飞到终点,NO
2. 分别计算x和y的移动次数,次数绝对值不相等,NO
3. 剩余情况都是 YES
以下是我的AC代码(代码后面是拆分解):
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x1,y1,x2,y2,x,y;
cin >> x1 >> y1 >> x2 >> y2 >> x >> y;
string s=(((x2-x1)%x || (y2-y1)%y) || abs((x2-x1)/x)%2!=abs((y2-y1)/y)%2)?"NO":"YES";
cout << s << endl;
return 0;
}
/*
int a=abs((x2-x1)/x),b=abs((y2-y1)/y);
if( ((x2-x1)%x || (y2-y1)%y) || a%2!=b%2 )
cout << "NO" << endl;
else
cout << "YES" << endl;
*/
上一篇: Image Pyramid
推荐阅读
-
Educational Codeforces Round 71 (Rated for Div. 2)E. XOR Guessing
-
Educational Codeforces Round 97 (Rated for Div. 2) D. Minimal Height Tree
-
Educational Codeforces Round 60 (Rated for Div. 2) ----A - Best Subsegment(思维题)
-
Codeforces Round #583 (Div. 1 + Div. 2,) D. Treasure Island(dfs+思维)
-
Educational Codeforces Round 23#A. Treasure Hunt
-
Educational Codeforces Round 85 (Rated for Div. 2) C. Circle of Monsters(前缀和 预处理 贪心)
-
Educational Codeforces Round 38-D- Buy a Ticket(SPFA)
-
Educational Codeforces Round 98 (Rated for Div. 2) A-E 题解
-
Codeforces 1201D - Treasure Hunting Codeforces Round #577 (Div. 2)
-
Educational Codeforces Round 93 (Rated for Div. 2) A. Bad Triangle