题目描述

Your friend from Manhattan is visiting you in Amsterdam. Because she can only stay for a short while, she wants to see as many tourist attractions in Amsterdam in as little time as possible. To do that, she needs to be able to figure out how long it takes her to walk from one landmark to another. In her hometown, that is easy: to walk from point m = (mx, my) to point n = (nx, ny) in Manhattan you need to walk a distance |nx − mx | + |ny − my |, since Manhattan looks like a rectangular grid of city blocks. However, Amsterdam is not well approximated by a rectangular grid. Therefore, you have taken it upon yourself to figure out the shortest distances between attractions in Amsterdam. With its canals, Amsterdam looks much more like a half-disc, with streets radiating at regular angles from the center, and with canals running the arc of the circle at equally spaced intervals. A street corner is given by the intersection of a circular canal and a street which radiates from the city center.

Depending on how accurately you want to model the street plan of Amsterdam, you can split the city into more or fewer half rings, and into more or fewer segments. Also, to avoid conversion problems, you want your program to work with any unit, given as the radius of the half circle. Can you help your friend by writing a program which computes the distance between any two street corners in Amsterdam, for a particular approximation?

输入

The input consists of
• One line with two integers M, N and a floating point number R.
– 1 ≤ M ≤ 100 is the number of segments (or ‘pie slices’) the model of the city is split into.
– 1 ≤ N ≤ 100 is the number of half rings the model of the city is split into.
– 1 ≤ R ≤ 1000 is the radius of the city.
• One line with four integers, ax, ay, bx, by, with 0 ≤ ax, bx ≤ M, and 0 ≤ ay, by ≤ N, the coordinates of two corners in the model of Amsterdam.

输出

Output a single line containing a single floating point number, the least distance needed to travel from point a to point b following only the streets in the model. The result should have an absolute or relative error of at most 10−6.

样例输入

6 5 2.0
1 3 4 2

样例输出

1.65663706143592
弧长不一定是最短的。。。。
然后不要纠结误差之类的

Amsterdam Distance的更多相关文章

  1. 2017 Benelux Algorithm Programming Contest (BAPC 17) Solution

    A - Amsterdam Distance 题意:极坐标系,给出两个点,求最短距离 思路:只有两种方式,取min  第一种,先走到0点,再走到终点 第二种,走到同一半径,再走过去 #include ...

  2. gym101666题解

    A Amsterdam Distance 题意 求圆环上的两点距离. 分析 显然是沿半径方向走到内圈再走圆弧最短. 代码 #include <bits/stdc++.h> using na ...

  3. [LeetCode] Total Hamming Distance 全部汉明距离

    The Hamming distance between two integers is the number of positions at which the corresponding bits ...

  4. [LeetCode] Hamming Distance 汉明距离

    The Hamming distance between two integers is the number of positions at which the corresponding bits ...

  5. [LeetCode] Rearrange String k Distance Apart 按距离为k隔离重排字符串

    Given a non-empty string str and an integer k, rearrange the string such that the same characters ar ...

  6. [LeetCode] Shortest Distance from All Buildings 建筑物的最短距离

    You want to build a house on an empty land which reaches all buildings in the shortest amount of dis ...

  7. [LeetCode] Shortest Word Distance III 最短单词距离之三

    This is a follow up of Shortest Word Distance. The only difference is now word1 could be the same as ...

  8. [LeetCode] Shortest Word Distance II 最短单词距离之二

    This is a follow up of Shortest Word Distance. The only difference is now you are given the list of ...

  9. [LeetCode] Shortest Word Distance 最短单词距离

    Given a list of words and two words word1 and word2, return the shortest distance between these two ...

随机推荐

  1. 19 01 15 django 数据库设计模型 管理站点 注意:在引入外键在django 2以上改版

    模型设计 我们之前操作数据库是通过写sql语句  ORM框架    可以通过不写sql  语句来进行操作数据库 1.定义模型类 模型类定义在models.py文件中,继承自models.Model类. ...

  2. 18 12 `12 WSGI 协议

    所谓wsig 协议  就是把web框架 和服务器进行分开  然后通过 wisg协议 进行连接  这样子可以随时替换web框架  或者 更换服务器 解耦 (现在学的内容里 静态连接一般是放在服务器里  ...

  3. 两个exe共享内存数据

    unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...

  4. idea拉取git项目并创建为maven项目(新创建github项目)

    0 环境 系统环境:win10 编辑器:idea 1 正文 1 clone项目 跟着提示yes 下一步 2 在根节点添加pom.xml(maven) <?xml version="1. ...

  5. [软件] Omnigraffle

    一个商业软件, mac下画画图, 还挺好用的. 网上可以找到可用的注册码 https://blog.csdn.net/glw0223/article/details/90736751

  6. (4)关于Alpha通道问题

    其实,我还是不理解,我还是先把我目前懂得和觉得有用的东西先存下来 =================================================================== ...

  7. Go语言-并发模式-资源池实例(pool)

    Go语言并发模式 利用goroutine和channel进行go的并发模式,实现一个资源池实例(<Go语言实战>书中实例稍作修改) 资源池可以存储一定数量的资源,用户程序从资源池获取资源进 ...

  8. UML-设计对象时涉及的制品有哪些?

    1.SSD.系统操作.交互图--->用例实现 1).通信图 2).顺序图 将SSD中的系统操作作为领域层控制器对象的起始消息.这是关键. 2.用例--->用例实现 在整个开发过程中,业务人 ...

  9. pycharm2018专业版

    https://blog.csdn.net/moshanghuali/article/details/94396935 1 下载Pycharm专业版2018.3.1许多人直接在官网直接下载,默认的都是 ...

  10. 微信官方小程序示例demo 微信开发者工具打开不显示云开发按钮

    如果直接打开官方的demo,微信开发者工具上是不显示云开发按钮的. 是因为默认appid是测试号.要换成一个正式appid就会显示云开发按钮了. 分享一个朋友的人工智能教程.零基础!通俗易懂!风趣幽默 ...