Educational Codeforces Round 6 A. Professor GukiZ's Robot 水
Professor GukiZ makes a new robot. The robot are in the point with coordinates (x1, y1) and should go to the point (x2, y2). In a single step the robot can change any of its coordinates (maybe both of them) by one (decrease or increase). So the robot can move in one of the 8 directions. Find the minimal number of steps the robot should make to get the finish position.
The first line contains two integers x1, y1 ( - 109 ≤ x1, y1 ≤ 109) — the start position of the robot.
The second line contains two integers x2, y2 ( - 109 ≤ x2, y2 ≤ 109) — the finish position of the robot.
Print the only integer d — the minimal number of steps to get the finish position.
0 0
4 5
5
In the first example robot should increase both of its coordinates by one four times, so it will be in position (4, 4). After that robot should simply increase its y coordinate and get the finish position.
In the second example robot should simultaneously increase x coordinate and decrease y coordinate by one three times.
题意:
给你一个起点和一个终点,robot可以向自己所在起点的周围8个方向走,问你最短路?
题解:
答案就是max(abs(x2-x1),abs(y1-y2))
#include <cstdio>
#include <cstring>
#include <ctime>
#include <algorithm>
using namespace std;
typedef long long ll;
int x1,x2,y2,y1;
int main() {
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
printf("%d\n",max(abs(x2-x1),abs(y1-y2)) );
return ;
}
Educational Codeforces Round 6 A. Professor GukiZ's Robot 水的更多相关文章
- Educational Codeforces Round 6 D. Professor GukiZ and Two Arrays 二分
D. Professor GukiZ and Two Arrays 题目连接: http://www.codeforces.com/contest/620/problem/D Description ...
- Educational Codeforces Round 6 D. Professor GukiZ and Two Arrays
Professor GukiZ and Two Arrays 题意:两个长度在2000的-1e9~1e9的两个序列a,b(无序);要你最多两次交换元素,使得交换元素后两序列和的差值的绝对值最小:输出这 ...
- Educational Codeforces Round 9 A. Grandma Laura and Apples 水题
A. Grandma Laura and Apples 题目连接: http://www.codeforces.com/contest/632/problem/A Description Grandm ...
- [Educational Codeforces Round 16]E. Generate a String
[Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...
- [Educational Codeforces Round 16]D. Two Arithmetic Progressions
[Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...
- [Educational Codeforces Round 16]C. Magic Odd Square
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...
- [Educational Codeforces Round 16]B. Optimal Point on a Line
[Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line wi ...
- [Educational Codeforces Round 16]A. King Moves
[Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board ...
- Educational Codeforces Round 6 C. Pearls in a Row
Educational Codeforces Round 6 C. Pearls in a Row 题意:一个3e5范围的序列:要你分成最多数量的子序列,其中子序列必须是只有两个数相同, 其余的数只能 ...
随机推荐
- GO语言UDP小笔记
<pre style="margin-top: 0px; margin-bottom: 0px;"><span style=" color:#0000f ...
- 用jquery ajax做的select菜单,选中的效果
//用server端语言赋值给js变量 var departmentId = '<%=提交的值 %>', deviceId='<%=提交的值 %>' $(fun ...
- 2015.04.23,外语,读书笔记-《Word Power Made Easy》 12 “如何奉承朋友” SESSION 33
1.eat, drink, and be merry 拉丁动词vivo(to live),加上名词vita(life),是许多重要英文词汇的来源. convivo是拉丁动词to live togeth ...
- 【POJ 2481】 Cows
[题目链接] http://poj.org/problem?id=2481 [算法] 树状数组 注意特判两头牛的s,e值相同 [代码] #include <algorithm> #incl ...
- 2017第34周复习Java总结
从上周日开始对工作中遇到的Java相关的知识进行总结整理.先是回顾了Java关键字,重点说了static关键字的用法:修饰变量.程序块.内部类.方法.还静态导包:重点说了final关键字可以修饰类.方 ...
- SQL Server 内存使用情况
• 查看设置的最大与最小内存: exec sp_configure 'max server memory (MB)' exec sp_configure 'min server memory (MB) ...
- Dragon Balls[HDU3635]
Dragon Balls Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- Eclipse中执行Ant脚本出现Could not find the main class的问题及解
试过了:https://blog.csdn.net/bookroader/article/details/2300337 但是不管用,偶然看到这篇没有直接关系的 https://blog.csdn.n ...
- protocol 和delegate(协议和代理)的区别
定义 protocol:中文叫协议,一个只有方法体(没有具体实现)的类,Java中称作接口,实现协议的类必须实现协议中@required标记的方法(如果有的话): delegate:中文叫代理或委托, ...
- 备份和恢复ZBrush文件
ZBrush可以自动保存绘图的备份副本,并在发生系统错误时提醒您恢复备份副本.当ZBrush软件遇到崩溃.导致错误.非正常退出的时候,可能之前所做的努力就会功亏一篑,那么,在ZBrush软件中能否将文 ...