题目描述

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. 字符串编码研究:Unicode

    Unicode Unicode 编码系统可分为编码方式和实现方式两个层次. 1.编码方式 Unicode字符平面映射定义了所有的Unicode字符集. 2.实现方式(UTF8,UTF16) UTF-8 ...

  2. MST(最小生成树)——Prim算法——HDU 1879-继续畅通工程

    Prim算法很好理解,特别是学完了迪杰斯特拉算法之后,更加能理解Prim的算法思想 和迪杰斯特拉算法差不多,由于最后要形成连通图,故任意指定一个点,作为初始点,遍历所有点,以当前最小权值的点(和迪杰斯 ...

  3. 吴裕雄--天生自然 JAVASCRIPT开发学习: DOM

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  4. 同行评审|keywords

    审稿流程: 初审 直接被拒,editor开组会讨论的结果 论文水平低 不符合刊物宗旨和要求 同行评审: 单盲评审 双盲评审:限制审稿人倾向 公开评审PNAS Analyse search result ...

  5. Linux安装已编译好的FFmpeg,基于centos7

    1.访问https://johnvansickle.com/ffmpeg/ 2.下载地址:https://johnvansickle.com/ffmpeg/releases/ffmpeg-releas ...

  6. Activity组件:(一)通过显式意图和隐式意图来实现Activity间的跳转

    一.通过显式意图来实现Activity间的跳转 显式意图是指在创建Intent对象时就指定接受者组件 /** * 下面是通过显式意图进行跳转,即明确写出要跳转到SecondActivity.class ...

  7. JunOS SRX firewal Web authentication(转)

    转载自:https://srxasa.wordpress.com/2011/12/11/junos-srx-firewal-web-authentication/ JunOS SRX firewal ...

  8. [HAOI2018]苹果树(组合数学)

    首先有个很奇妙而且很有用的性质:每个二叉树对应唯一的中序遍历,然后每个二叉树出现概率相同.所以n个节点的二叉树形态是n!种(题目中说了*n!已经是提示了),对每种方案求和即可得到期望.令f[i]表示i ...

  9. Dynamics CRM - Plug-in Class 和 Workflow Class 的用法与区别

    在 Dynamics CRM 开发中,我们可以使用 JavaScript 在前端对 Entity Form 进行数据操作,与此同时,我们也可以使用 C# 写后台插件,其中就包括了 Plug-in Cl ...

  10. abstract关键字、final关键字、static关键字、访问修饰符详解

     abstract关键字.final关键字.static关键字.访问修饰符详解 abstract关键字: final关键字: static关键字: 访问修饰符: