CodeFroces 817A Treasure Hunt(构造题)
来源:互联网 发布:windows内部运行机制 编辑:程序博客网 时间:2024/06/05 23:00
一开始没有什么想法,后来发现其实他们都可以看成是从0到abs(x2 - x1),每次步长是x,并且移动的奇偶是固定的,所以我们只需要判断一下两个数字移动的次数的奇偶是否相同即可。然后就wa了。
还有一个就是要判断是否可以用x的步长刚好到达abs(x2 - x1),如果无法到达也是直接输出NO。
代码如下:
#include<cstdio> #include<algorithm>using namespace std;int main() {#ifndef ONLINE_JUDGE//freopen("in.txt", "r", stdin);// freopen("out.txt", "w", stdout);#endifint x1, x2, y1, y2, x, y;scanf("%d%d%d%d", &x1, &y1, &x2, &y2);scanf("%d%d", &x, &y);int a = abs(x2 - x1), b = abs(y2 - y1);int c = (a / x) % 2, d = (b / y) % 2;if(c != d || (a % x) || (b % y))printf("NO\n");elseprintf("YES\n");return 0;}
阅读全文
0 0
- CodeFroces 817A Treasure Hunt(构造题)
- Codeforces 817A Treasure Hunt
- CodeFroces 831A. Unimodal Array(构造题)
- Educational Codeforces Round 23 A. Treasure Hunt
- Educational Codeforces Round 23#A. Treasure Hunt
- Treasure Hunt II - ZOJ 3627 想法题
- Google Treasure Hunt 2008
- pku1066 Treasure Hunt
- poj 1066 Treasure Hunt
- POJ 1066 Treasure Hunt
- POJ 1066 Treasure Hunt
- ceoi 2011 treasure hunt
- zoj 1158 Treasure Hunt
- POJ 1066 Treasure Hunt
- poj 1066 Treasure Hunt
- POJ 1066 Treasure Hunt
- poj 1066 Treasure Hunt
- POJ 1066 Treasure Hunt
- Java爬虫进阶-Selenium+PhantomJs的运用
- maven二
- 技术与技术人员的价值
- voronoi diagram
- 关于AJAX轮询简单代码
- CodeFroces 817A Treasure Hunt(构造题)
- rbd-mirror 技术内幕
- .json.JSONException: java.lang.NoSuchMethodException: bean.Equipmentplan.<init>()
- Android中Adapter的notifyDataSetInvalidated()和notifyDataSetChanged()的区别
- Android 重写系统Crash处理类,保存Crash信息到SD卡 和 完美退出程序的方法
- C语言中"."和"->"的区别
- 复盘_8月(第4周工作复盘)
- 重建二叉树
- Xcode 查看运行时ViewController结构