2019 GDUT Rating Contest II : Problem F. Teleportation
题面:
Problem F. Teleportation
Farmer John’s farm is built along a single long straight road, so any location on his farm can be described simply using its position along this road (effectively a point on the number line). A teleporter is described by two numbers x and y, where manure brought to location x can be instantly transported to location y, or vice versa.
题目描述:
题目分析:




1 #include <cstdio>
2 #include <iostream>
3 #include <algorithm>
4 #include <cmath>
5 using namespace std;
6
7 int main(){
8 int a, b, x, y;
9 cin >> a >> b >> x >> y;
10
11 int res = 1e9; //设为"无穷大"
12 res = min(res, abs(a-b)); //第一种情况
13 res = min(res, abs(a-x)+abs(b-y)); //第二种情况
14 res = min(res, abs(a-y)+abs(b-x)); //第三种情况
15
16 cout << res << endl;
17 return 0;
18 }
2019 GDUT Rating Contest II : Problem F. Teleportation的更多相关文章
- 2019 GDUT Rating Contest II : Problem G. Snow Boots
题面: G. Snow Boots Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest II : Problem C. Rest Stops
题面: C. Rest Stops Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest II : Problem B. Hoofball
题面: 传送门 B. Hoofball Input file: standard input Output file: standard output Time limit: 5 second Memor ...
- 2019 GDUT Rating Contest III : Problem D. Lemonade Line
题面: D. Lemonade Line Input file: standard input Output file: standard output Time limit: 1 second Memo ...
- 2019 GDUT Rating Contest II : A. Taming the Herd
题面: A. Taming the Herd Input file: standard input Output file: standard output Time limit: 1 second Me ...
- 2019 GDUT Rating Contest I : Problem H. Mixing Milk
题面: H. Mixing Milk Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest I : Problem A. The Bucket List
题面: A. The Bucket List Input file: standard input Output file: standard output Time limit: 1 second Me ...
- 2019 GDUT Rating Contest I : Problem G. Back and Forth
题面: G. Back and Forth Input file: standard input Output file: standard output Time limit: 1 second Mem ...
- 2019 GDUT Rating Contest III : Problem E. Family Tree
题面: E. Family Tree Input file: standard input Output file: standard output Time limit: 1 second Memory ...
随机推荐
- l2-002 链表去重 (未解决)
L2-002. 链表去重 时间限制 300 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 给定一个带整数键值的单链表L,本题要求你编写程序,删除 ...
- 5分钟学Go 基础01:初识 Go 的第一印象是薪水可观
本文首发于公众号「5分钟学Go」,一个让你每次花 5 分钟就能掌握一个技能点的公众号.目前在博主连更 5 分钟学Go系列,大家可以关注下,第一时间掌握Go技能.如果想要加群交流,可以在公众号后台回复「 ...
- 最新 React 源码学习笔记
最新 React 源码学习笔记 v17.x.x 框架架构 核心算法 设计模式 编码风格 项目结构 为什么出现 解决了什么问题 有哪些应用场景 refs https://github.com/learn ...
- React Big Changes All in One
React Big Changes All in One React 重大更新 React Versions React 版本变更 https://reactjs.org/versions/ sema ...
- github & personal access token
github & personal access token OAuth https://github.com/xgqfrms/webtrc-in-action/issues/1#issuec ...
- how to open a terminal in finder folder of macOS
how to open a terminal in finder folder of macOS shit service demo refs https://lifehacker.com/launc ...
- ts 在Function上创建静态属性和方法
interface IMessage { (value: any): void; success(): void; error(): void; version: string; } const Me ...
- 在gradle中构建java项目
目录 简介 构建java项目的两大插件 管理依赖 编译代码 管理resource 打包和发布 生成javadoc 简介 之前的文章我们讲到了gradle的基本使用,使用gradle的最终目的就是为了构 ...
- 纯js日历插件
成品的效果图 1.HTML文件 <!DOCTYPE html> <html lang="en"> <head> <meta charset ...
- winform导出csv
public void ExportToSvc1(string strFileName) { string strPath = strFileName + ".csv"; Stri ...