[COCI2006-2007#1] Herman

洛谷:https://www.luogu.org/problemnew/show/P4326

题目描述

The 19th century German mathematician Hermann Minkowski investigated a non-Euclidian geometry, called the taxicab geometry. In taxicab geometry the distance between two points T_{1}(x_{1},y_{1}) and T_{2}(x_{2},y_{2}) is defined as: D\left ( T_{1},T_{2} \right )=\left | x_{1}-x_{2} \right |+\left | y_{1}-y_{2} \right | All other definitions are the same as in Euclidian geometry, including that of a circle: A circle is the set of all points in a plane at a fixed distance (the radius) from a fixed point (the centre of the circle). We are interested in the difference of the areas of two circles with radius R, one of which is in normal (Euclidian) geometry, and the other in taxicab geometry. The burden of solving this difficult problem has fallen onto you.

19世纪的德国数学家赫尔曼·闵可夫斯基(Hermann Minkowski)研究了一种名为出租车几何学的非欧几何。 在出租车几何里T_{1}(x_{1},y_{1}),T_{2}(x_{2},y_{2})两点之间的距离被定义为dis\left ( T_{1},T_{2} \right )=\left | x_{1}-x_{2} \right |+\left | y_{1}-y_{2} \right |(曼哈顿距离)。 其他定义均与欧几里得几何相同。
例如圆的定义:在同一平面内,到定点(圆心)的距离等于定长(半径)的点的集合。

我们对欧几里得几何与出租车几何两种定义下半径为R的圆的面积很感兴趣。解决这个问题的重担就落在你身上了。

输入输出格式

输入格式

仅有一行为圆的半径R。 (R≤10000)

输出格式

第一行输出欧几里得几何下半径为R的圆的面积,第二行输出出租车几何下半径为R的圆的面积。

注意:你的输出与标准答案绝对误差不超过0.0001将会被认为正确

输入输出样例

输入样例     21

输出样例

扫描二维码关注公众号,回复: 9279679 查看本文章
1385.442360
882.000000

解释

我们假设R=3

众所周知欧几里得几何中的圆长这样:

圆 - 欧几里得几何

那么出租车几何中的圆呢?

我们来看一下:

欧几里得几何中距离公式为dis\left ( T_{1},T_{2} \right )=\sqrt{\left ( x^{_{1}}-x_{2} \right )^{2}+\left ( y^{_{1}}-y_{2} \right )^{2}},所以标准圆的面积表示为S_{1}=x^{2}+y^{2}

而出租车几何中距离公式为dis\left ( T_{1},T_{2} \right )=\left | x_{1}-x_{2} \right |+\left | y_{1}-y_{2} \right |,所以标准圆的面积表示为S_{2}=\left | x \right |+\left | y \right |

你没有看错!这个“圆”居然是正方形!

圆 - 出租车几何

这么鬼畜的圆我还是头一回见。。。

(本来还以为是考第二定义啥的呢)

那就真相大白了

# -*- coding: utf-8 -*-
import math
R = input()
R = int(R)
s1 = R**2 * math.pi
s2 = R**2 * 2
print('%.6f' % s1)
print('%.6f' % s2)
发布了58 篇原创文章 · 获赞 40 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/baidu_41248654/article/details/94192776