Educational Codeforces Round 23 A. Treasure Hunt
来源:互联网 发布:php网上订餐系统 编辑:程序博客网 时间:2024/06/05 17:23
Captain Bill the Hummingbird and his crew recieved an interesting challenge offer. Some stranger gave them a map, potion of teleportation and said that only this potion might help them to reach the treasure.
Bottle with potion has two values x and y written on it. These values define four moves which can be performed using the potion:
Map shows that the position of Captain Bill the Hummingbird is (x1, y1) and the position of the treasure is (x2, y2).
You task is to tell Captain Bill the Hummingbird whether he should accept this challenge or decline. If it is possible for Captain to reach the treasure using the potion then output "YES", otherwise "NO" (without quotes).
The potion can be used infinite amount of times.
The first line contains four integer numbers x1, y1, x2, y2 ( - 105 ≤ x1, y1, x2, y2 ≤ 105) — positions of Captain Bill the Hummingbird and treasure respectively.
The second line contains two integer numbers x, y (1 ≤ x, y ≤ 105) — values on the potion bottle.
Print "YES" if it is possible for Captain to reach the treasure using the potion, otherwise print "NO" (without quotes).
0 0 0 62 3
YES
1 1 3 61 5
NO
In the first example there exists such sequence of moves:
- — the first type of move
- — the third type of move
这道题目的意思就是给定一个起点一个终点坐标,然后用题目中给的四种方法走任意次(X,Y的值在下一行输入)能从起点走到终点就输出YES,反之NO
其实也就是用终点的坐标减去起点坐标求一个x和y的绝对值
然后这个值必须是X,Y的倍数(对X,Y去余为0)
然后必须都是偶数倍,如果是奇数倍则不能x,y同时等于X,Y,
只有偶数的时候如果哪个超过了,可以用偶数次的时间来等另一个。所以必须是偶数倍
代码如下:
#include<bits/stdc++.h>#include<iostream>using namespace std;int main(){ int x1,y1,x2,y2,x,y,x3,y3; cin>>x1>>y1>>x2>>y2; x3=abs(x1-x2);y3=abs(y1-y2); cin>>x>>y; //why if(x3%x==0&&y3%y==0&&(x3/x)%2==(y3/y)%2) { cout<<"YES"; } else cout<<"NO"; return 0;}
- Educational Codeforces Round 23 A. Treasure Hunt
- Educational Codeforces Round 23#A. Treasure Hunt
- Codeforces 817A Treasure Hunt
- Educational Codeforces Round 23 A
- Educational Codeforces Round 23 A-F
- Educational Codeforces Round 5 A
- Educational Codeforces Round 20 A
- Educational Codeforces Round 21 A
- codeforces Educational Codeforces Round 21 A
- Codeforces Round #282 (Div. 1) A. Treasure
- Codeforces Round #282 (Div. 1) A. Treasure
- Educational Codeforces Round 23总结
- [CF] Educational Codeforces Round 23
- Educational Codeforces Round 23 B
- Educational Codeforces Round 23 题解
- Educational Codeforces Round 1 A. Tricky Sum
- Educational Codeforces Round 1 (A)模拟
- Educational Codeforces Round 1 A. Tricky Sum
- Codeforces Kefa and First Steps
- 操作系统(四):文件管理、文件系统
- 【随笔】谷歌浏览器+终端命令行下载美拍视频
- 通向架构师的道路(第一天)之Apache整合Tomcat
- boost thread warning C4191和algorithm warning C4242
- Educational Codeforces Round 23 A. Treasure Hunt
- Java项目中读取properties文件
- DailyRollingFileAppender的使用
- Android Alertdialog使用案例
- 2017版Intellij IDEA入门教程
- 5个理由让你选择Go,抛弃Python
- 深入理解DIP、IoC、DI以及IoC容器
- sourceinsight破解的关键点
- Git push与pull的默认行为