• 洛谷 P4326 [COCI2006-2007#1] Herman


    【题目描述】
    The 19th century German mathematician Hermann Minkowski investigated a non-Euclidian geometry, called the taxicab geometry. In taxicab geometry the distance between two points T1(x1, y1) and T2(x2, y2) is defined as: D(T1,T2) = |x1 - x2| + |y1 - y2| 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.

    【输入格式】
    The first and only line of input will contain the radius R, an integer smaller than or equal to 10000.

    【输出格式】
    On the first line you should output the area of a circle with radius R in normal (Euclidian) geometry. On the second line you should output the area of a circle with radius R in taxicab geometry. Note: Outputs within ±0.0001 of the official solution will be accepted.

    【题意翻译】
    19世纪的德国数学家赫尔曼·闵可夫斯基(Hermann Minkowski)研究了一种名为出租车几何学的非欧几何。 在出租车几何里T1(x1,y1),T2​(x2​,y2​)两点之间的距离被定义为dis(T1,T2)=∣x1−x2∣+∣y1−y2∣(曼哈顿距离)。 其他定义均与欧几里得几何相同。
    例如圆的定义:在同一平面内,到定点(圆心)的距离等于定长(半径)的点的集合。
    我们对欧几里得几何与出租车几何两种定义下半径为R的圆的面积很感兴趣。解决这个问题的重担就落在你身上了。

    【输入输出格式】

    {输入格式}
    仅有一行为圆的半径R。 (R≤10000)

    {输出格式}
    第一行输出欧几里得几何下半径为RRR的圆的面积,第二行输出出租车几何下半径为RRR的圆的面积。

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

    【输入输出样例】
    输入
    1

    输出
    3.141593
    2.000000

    【分析】
    1.精度:误差需小于0.0001,可用cmath库中自带的M_PI表示圆周率。

    【代码实现】

     1 #include <cstdio>
     2 #include <cmath>
     3 using namespace std;
     4 int main()
     5 {
     6     double r,so,sh;
     7     scanf("%lf",&r);
     8     so=M_PI*r*r;
     9     sh=2*r*r;
    10     printf("%.6lf 
    %.6lf",so,sh);
    11     return 0;
    12 }
  • 相关阅读:
    stm32自带的flash分布图
    leetcode21
    使用redis缓存数据需要注意的问题以及个人的一些思考和理解
    Chapter 2 Open Book——2
    spring管理事务需要注意的
    如何避免在简单业务逻辑上面的细节上面出错
    leetcode387
    黑天鹅-简记
    java方法中只有值传递,没有引用传递
    Chapter 2 Open Book——1
  • 原文地址:https://www.cnblogs.com/TheZealous/p/14293394.html
Copyright © 2020-2023  润新知