洛谷.欧式几何

题意翻译
19世纪的德国数学家赫尔曼·闵可夫斯基(Hermann Minkowski)研究了一种名为出租车几何学的非欧几何。 在==出租车几何里T1(x1,y1),T2(x2,y2)两点之间的距离被定义为dis(T1,T2)=|x1-x2|+|y1-y2|(曼哈顿距离)。 其他定义均与欧几里得几何相同。
例如圆的定义:在同一平面内,到定点(圆心)的距离等于定长(半径)的点的集合。我们对欧几里得几何与出租车几何两种定义下半径为RR的圆的面积很感兴趣。解决这个问题的重担就落在你身上了。
输入输出格式
输入格式
仅有一行为圆的半径R。 (R≤10000)
输出格式
第一行输出欧几里得几何下半径为R的圆的面积,第二行输出出租车几何下半径为RR的圆的面积。
注意:你的输出与标准答案绝对误差不超过±0.0001将会被认为正确
题目描述
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.

首先分析一下这个东东:
在出租车几何下,距离公式是|x1-x2|+|y1-y2|。同样,我们可以求出它的标准方程。
设一个点(x,y)(x,y),在出租车几何下,它到原点(0,0)(0,0)的距离是|x-0|+|y-0|∣x−0∣+∣y−0∣,即|x|+|y|∣x∣+∣y∣。我们令上式等于定长RR,可得公式|x|+|y|=R∣x∣+∣y∣=R。这就是出租车几何下圆的标准方程。
那么我们把它画出来吧。
在四个象限中,分别设:
x为正,y为正,得x+y=Rx+y=R
x为正,y为负,得x-y=Rx−y=R
x为负,y为负,得-x-y=R−x−y=R
x为负,y为正,得-x+y=R−x+y=R
随便设一个RR,然后描点连线,这时这个“圆”的样子居然是······正!方!形?!

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<stack>
#include<queue>
#define PI 3.14159265358979323
#include<functional>
#include<vector>
#include <iostream>

using namespace std;
typedef long long ll;
const int maxn=1e5;
const int N = 1e6 + 10;
const int INF = -10234567;

bool cmp(int a,int b)
{
    return a>b;
}

struct node
{
    int num;
    int pri;
};

int main()
{
    double n;
    cin>>n;
    printf("%.6lf\n%.6lf",n*n*PI,n*n*2);
    return 0;
}需要注意PI的精度
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值